Skip to content

Commit

Permalink
Retain pause.exe as entrypoint for default pause images (#1615) (#1634)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6cd5572)

Signed-off-by: Kirtana Ashok <Kirtana.Ashok@microsoft.com>
Co-authored-by: Kirtana Ashok <Kirtana.Ashok@microsoft.com>
  • Loading branch information
kiashok and Kirtana Ashok committed Feb 1, 2023
1 parent 5d5b210 commit f985798
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cmd/containerd-shim-runhcs-v1/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"sync"

"github.com/Microsoft/hcsshim/internal/log"
Expand Down Expand Up @@ -228,10 +229,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.
Expand Down

0 comments on commit f985798

Please sign in to comment.