TestIssue10589 is used as regression case for issue 10589. This issue was caused by a race between init exits and new exec process tracking inside the shim. The test operates by controlling the time between when the shim invokes "runc exec" and when the actual "runc exec" is triggered. This allow
(t *testing.T)
| 1630 | // |
| 1631 | // https://github.com/containerd/containerd/issues/10589 |
| 1632 | func TestIssue10589(t *testing.T) { |
| 1633 | if f := os.Getenv("RUNC_FLAVOR"); f != "" && f != "runc" { |
| 1634 | t.Skip("test requires runc") |
| 1635 | } |
| 1636 | |
| 1637 | client, err := newClient(t, address) |
| 1638 | require.NoError(t, err) |
| 1639 | t.Cleanup(func() { |
| 1640 | client.Close() |
| 1641 | }) |
| 1642 | |
| 1643 | var ( |
| 1644 | image Image |
| 1645 | ctx, cancel = testContext(t) |
| 1646 | id = t.Name() |
| 1647 | ) |
| 1648 | t.Cleanup(cancel) |
| 1649 | |
| 1650 | image, err = client.GetImage(ctx, testImage) |
| 1651 | require.NoError(t, err) |
| 1652 | |
| 1653 | // 1. Create a sleeping container |
| 1654 | t.Log("1. Create a sleeping container") |
| 1655 | container, err := client.NewContainer(ctx, id, |
| 1656 | WithNewSnapshot(id, image), |
| 1657 | WithNewSpec(oci.WithImageConfig(image), |
| 1658 | withProcessArgs("sleep", "inf"), |
| 1659 | oci.WithAnnotations(map[string]string{ |
| 1660 | "oci.runc.failpoint.profile": "delayExec", |
| 1661 | }), |
| 1662 | ), |
| 1663 | WithRuntime(client.Runtime(), &options.Options{ |
| 1664 | BinaryName: "runc-fp", |
| 1665 | }), |
| 1666 | ) |
| 1667 | require.NoError(t, err, "create container") |
| 1668 | t.Cleanup(func() { |
| 1669 | ctx, cancel := context.WithTimeout(ctx, 10*time.Second) |
| 1670 | err := container.Delete(ctx, WithSnapshotCleanup) |
| 1671 | if err != nil { |
| 1672 | t.Log("delete err", err) |
| 1673 | } |
| 1674 | cancel() |
| 1675 | }) |
| 1676 | |
| 1677 | task, err := container.NewTask(ctx, empty()) |
| 1678 | require.NoError(t, err, "create task") |
| 1679 | t.Cleanup(func() { |
| 1680 | ctx, cancel := context.WithTimeout(ctx, 2*time.Second) |
| 1681 | st, err := task.Delete(ctx, WithProcessKill) |
| 1682 | t.Log("exit status", st) |
| 1683 | if err != nil { |
| 1684 | t.Log("kill err", err) |
| 1685 | } |
| 1686 | cancel() |
| 1687 | }) |
| 1688 | |
| 1689 | err = task.Start(ctx) |
nothing calls this directly
no test coverage detected
searching dependent graphs…