Skip to content

Commit 6cd5572

Browse files
kiashokKirtana Ashok
andauthored
Retain pause.exe as entrypoint for default pause images (#1615)
Signed-off-by: Kirtana Ashok <[email protected]> Signed-off-by: Kirtana Ashok <[email protected]> Co-authored-by: Kirtana Ashok <[email protected]>
1 parent d6dd825 commit 6cd5572

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

  • cmd/containerd-shim-runhcs-v1

cmd/containerd-shim-runhcs-v1/pod.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"os"
99
"path/filepath"
10+
"strings"
1011
"sync"
1112

1213
"github.com/Microsoft/hcsshim/internal/log"
@@ -238,10 +239,20 @@ func createPod(ctx context.Context, events publisher, req *task.CreateTaskReques
238239
}
239240
} else {
240241
if isWCOW {
241-
// The pause container activation will immediately exit on Windows
242+
defaultArgs := "c:\\windows\\system32\\cmd.exe"
243+
// For the default pause image, the entrypoint
244+
// used is pause.exe
245+
// If the default pause image is not used for pause containers,
246+
// the activation will immediately exit on Windows
242247
// because there is no command. We forcibly update the command here
243-
// to keep it alive.
244-
s.Process.CommandLine = "cmd /c ping -t 127.0.0.1 > nul"
248+
// to keep it alive only for non-default pause images.
249+
// TODO: This override can be completely removed from containerd/1.7
250+
if (len(s.Process.Args) == 1 && strings.EqualFold(s.Process.Args[0], defaultArgs)) ||
251+
strings.EqualFold(s.Process.CommandLine, defaultArgs) {
252+
log.G(ctx).Warning("Detected CMD override for pause container entrypoint." +
253+
"Please consider switching to a pause image with an explicit cmd set")
254+
s.Process.CommandLine = "cmd /c ping -t 127.0.0.1 > nul"
255+
}
245256
}
246257
// LCOW (and WCOW Process Isolated for the time being) requires a real
247258
// task for the sandbox.

0 commit comments

Comments
 (0)