diff --git a/lib/sandbox/sandbox.go b/lib/sandbox/sandbox.go index 7624b072..641e1734 100644 --- a/lib/sandbox/sandbox.go +++ b/lib/sandbox/sandbox.go @@ -168,9 +168,6 @@ const ( // NsRunDir is the default directory in which running network namespaces // are stored NsRunDir = "/var/run/netns" - // PodInfraCommand is the default command when starting a pod infrastructure - // container - PodInfraCommand = "/pause" ) var ( diff --git a/server/sandbox_run.go b/server/sandbox_run.go index 5ba007c2..951e113e 100644 --- a/server/sandbox_run.go +++ b/server/sandbox_run.go @@ -186,15 +186,6 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest // setup defaults for the pod sandbox g.SetRootReadonly(true) - if s.config.PauseCommand == "" { - if podContainer.Config != nil { - g.SetProcessArgs(podContainer.Config.Config.Cmd) - } else { - g.SetProcessArgs([]string{sandbox.PodInfraCommand}) - } - } else { - g.SetProcessArgs([]string{s.config.PauseCommand}) - } // set DNS options if req.GetConfig().GetDnsConfig() != nil { @@ -286,6 +277,20 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest g.SetProcessSelinuxLabel(processLabel) g.SetLinuxMountLabel(mountLabel) + containerKubeConfig := &pb.ContainerConfig{} + if s.config.PauseCommand != "" { + containerKubeConfig.Command = []string{s.config.PauseCommand} + } + processArgs, err := buildOCIProcessArgs(containerKubeConfig, &podContainer.Config.Config) + if err != nil { + return nil, err + } + if len(processArgs) == 0 { + g.Spec().Process = nil + } else { + g.SetProcessArgs(processArgs) + } + // create shm mount for the pod containers. var shmPath string if securityContext.GetNamespaceOptions().GetHostIpc() {