diff --git a/oci/oci.go b/oci/oci.go index 033c1fe3..af97b9df 100644 --- a/oci/oci.go +++ b/oci/oci.go @@ -17,8 +17,8 @@ import ( specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/Sirupsen/logrus" - "github.com/kubernetes-incubator/cri-o/utils" "github.com/containernetworking/cni/pkg/ns" + "github.com/kubernetes-incubator/cri-o/utils" "golang.org/x/sys/unix" "k8s.io/kubernetes/pkg/fields" pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" @@ -275,6 +275,7 @@ func (r *Runtime) StopContainer(c *Container) error { if err != nil && err != syscall.ESRCH { return fmt.Errorf("failed to kill process: %v", err) } + break } // Check if the process is still around err := unix.Kill(c.state.Pid, 0) diff --git a/server/server.go b/server/server.go index 7d0490cd..8f1ae391 100644 --- a/server/server.go +++ b/server/server.go @@ -15,7 +15,6 @@ import ( "github.com/kubernetes-incubator/cri-o/oci" "github.com/kubernetes-incubator/cri-o/server/apparmor" "github.com/kubernetes-incubator/cri-o/server/seccomp" - "github.com/kubernetes-incubator/cri-o/utils" "github.com/opencontainers/runc/libcontainer/label" rspec "github.com/opencontainers/runtime-spec/specs-go" "github.com/rajatchopra/ocicni" @@ -297,14 +296,6 @@ func seccompEnabled() bool { // New creates a new Server with options provided func New(config *Config) (*Server, error) { - // TODO: This will go away later when we have wrapper process or systemd acting as - // subreaper. - if err := utils.SetSubreaper(1); err != nil { - return nil, fmt.Errorf("failed to set server as subreaper: %v", err) - } - - utils.StartReaper() - if err := os.MkdirAll(config.ImageDir, 0755); err != nil { return nil, err } diff --git a/utils/utils.go b/utils/utils.go index dffbd92f..fd3544fd 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -6,7 +6,6 @@ import ( "io" "os" "os/exec" - "os/signal" "path/filepath" "strings" "syscall" @@ -14,9 +13,6 @@ import ( "github.com/Sirupsen/logrus" ) -// PRSetChildSubreaper is the value of PR_SET_CHILD_SUBREAPER in prctl(2) -const PRSetChildSubreaper = 36 - // ExecCmd executes a command with args and returns its output as a string along // with an error, if any func ExecCmd(name string, args ...string) (string, error) { @@ -49,11 +45,6 @@ func ExecCmdWithStdStreams(stdin io.Reader, stdout, stderr io.Writer, name strin return nil } -// SetSubreaper sets the value i as the subreaper setting for the calling process -func SetSubreaper(i int) error { - return Prctl(PRSetChildSubreaper, uintptr(i), 0, 0, 0) -} - // Prctl is a way to make the prctl linux syscall func Prctl(option int, arg2, arg3, arg4, arg5 uintptr) (err error) { _, _, e1 := syscall.Syscall6(syscall.SYS_PRCTL, uintptr(option), arg2, arg3, arg4, arg5, 0) @@ -135,40 +126,6 @@ func dockerRemove(container string) error { return err } -// StartReaper starts a goroutine to reap processes -func StartReaper() { - logrus.Infof("Starting reaper") - go func() { - sigs := make(chan os.Signal, 10) - signal.Notify(sigs, syscall.SIGCHLD) - for { - // Wait for a child to terminate - sig := <-sigs - for { - // Reap processes - var status syscall.WaitStatus - cpid, err := syscall.Wait4(-1, &status, syscall.WNOHANG, nil) - if err != nil { - if err != syscall.ECHILD { - logrus.Debugf("wait4 after %v: %v", sig, err) - } - break - } - if cpid < 1 { - break - } - if status.Exited() { - logrus.Debugf("Reaped process with pid %d, exited with status %d", cpid, status.ExitStatus()) - } else if status.Signaled() { - logrus.Debugf("Reaped process with pid %d, exited on %s", cpid, status.Signal()) - } else { - logrus.Debugf("Reaped process with pid %d", cpid) - } - } - } - }() -} - // StatusToExitCode converts wait status code to an exit code func StatusToExitCode(status int) int { return ((status) & 0xff00) >> 8