From 6cd5572970cf7c82813e9c29bf41d9b0bd435977 Mon Sep 17 00:00:00 2001 From: kiashok <99994218+kiashok@users.noreply.github.com> Date: Thu, 26 Jan 2023 12:43:52 -0800 Subject: [PATCH] Retain pause.exe as entrypoint for default pause images (#1615) Signed-off-by: Kirtana Ashok Signed-off-by: Kirtana Ashok Co-authored-by: Kirtana Ashok --- cmd/containerd-shim-runhcs-v1/pod.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/containerd-shim-runhcs-v1/pod.go b/cmd/containerd-shim-runhcs-v1/pod.go index 963474bb0d..5ebc4fa48d 100644 --- a/cmd/containerd-shim-runhcs-v1/pod.go +++ b/cmd/containerd-shim-runhcs-v1/pod.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "sync" "github.com/Microsoft/hcsshim/internal/log" @@ -238,10 +239,20 @@ func createPod(ctx context.Context, events publisher, req *task.CreateTaskReques } } else { if isWCOW { - // The pause container activation will immediately exit on Windows + defaultArgs := "c:\\windows\\system32\\cmd.exe" + // For the default pause image, the entrypoint + // used is pause.exe + // If the default pause image is not used for pause containers, + // the activation will immediately exit on Windows // because there is no command. We forcibly update the command here - // to keep it alive. - s.Process.CommandLine = "cmd /c ping -t 127.0.0.1 > nul" + // to keep it alive only for non-default pause images. + // TODO: This override can be completely removed from containerd/1.7 + if (len(s.Process.Args) == 1 && strings.EqualFold(s.Process.Args[0], defaultArgs)) || + strings.EqualFold(s.Process.CommandLine, defaultArgs) { + log.G(ctx).Warning("Detected CMD override for pause container entrypoint." + + "Please consider switching to a pause image with an explicit cmd set") + s.Process.CommandLine = "cmd /c ping -t 127.0.0.1 > nul" + } } // LCOW (and WCOW Process Isolated for the time being) requires a real // task for the sandbox.