From 005d30e8497cc43fca1eb0a440c61f0fc0e91bda Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Sun, 29 Jan 2023 12:02:49 +0800 Subject: [PATCH 1/2] deflake: TestContainerPids It is kind of race because `sleep 1s` is short live process. See: https://github.com/containerd/containerd/issues/7965#issuecomment-1383218025 Fixes: #7965 Signed-off-by: Wei Fu --- integration/client/client_unix_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/client/client_unix_test.go b/integration/client/client_unix_test.go index 67319580a..05ee02451 100644 --- a/integration/client/client_unix_test.go +++ b/integration/client/client_unix_test.go @@ -30,7 +30,7 @@ var ( testImage = images.Get(images.BusyBox) testMultiLayeredImage = images.Get(images.VolumeCopyUp) shortCommand = withProcessArgs("true") - longCommand = withProcessArgs("/bin/sh", "-c", "while true; do sleep 1; done") + longCommand = withProcessArgs("/bin/sh", "-c", "while true; do sleep 1d; done") ) func TestImagePullSchema1WithEmptyLayers(t *testing.T) { From 8886b05dc3bdc6ffd28c010bf7960c0071f7a97d Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Sun, 29 Jan 2023 17:24:11 +0800 Subject: [PATCH 2/2] integration: use sleep inf with busybox:1.36 Signed-off-by: Wei Fu --- integration/client/client_unix_test.go | 14 +++++++++++++- integration/images/image_list.go | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/integration/client/client_unix_test.go b/integration/client/client_unix_test.go index 05ee02451..0d7b7d49f 100644 --- a/integration/client/client_unix_test.go +++ b/integration/client/client_unix_test.go @@ -30,7 +30,19 @@ var ( testImage = images.Get(images.BusyBox) testMultiLayeredImage = images.Get(images.VolumeCopyUp) shortCommand = withProcessArgs("true") - longCommand = withProcessArgs("/bin/sh", "-c", "while true; do sleep 1d; done") + // NOTE: The TestContainerPids needs two running processes in one + // container. But busybox:1.36 sh shell, the `sleep` is a builtin. + // + // /bin/sh -c "type sleep" + // sleep is a shell builtin + // + // We should use `/bin/sleep` instead of `sleep`. And busybox sh shell + // will execve directly instead of clone-execve if there is only one + // command. There will be only one process in container if we use + // '/bin/sh -c "/bin/sleep inf"'. + // + // So we append `&& exit 0` to force sh shell uses clone-execve. + longCommand = withProcessArgs("/bin/sh", "-c", "/bin/sleep inf && exit 0") ) func TestImagePullSchema1WithEmptyLayers(t *testing.T) { diff --git a/integration/images/image_list.go b/integration/images/image_list.go index 023037f58..5be031d1f 100644 --- a/integration/images/image_list.go +++ b/integration/images/image_list.go @@ -48,7 +48,7 @@ var initOnce sync.Once func initImages(imageListFile string) { imageList = ImageList{ Alpine: "ghcr.io/containerd/alpine:3.14.0", - BusyBox: "ghcr.io/containerd/busybox:1.28", + BusyBox: "ghcr.io/containerd/busybox:1.36", Pause: "registry.k8s.io/pause:3.8", ResourceConsumer: "registry.k8s.io/e2e-test-images/resource-consumer:1.10", VolumeCopyUp: "ghcr.io/containerd/volume-copy-up:2.1",