diff --git a/libcontainerd/remote_unix.go b/libcontainerd/remote_unix.go index 64a28646be..eebbc886c6 100644 --- a/libcontainerd/remote_unix.go +++ b/libcontainerd/remote_unix.go @@ -21,8 +21,7 @@ import ( "github.com/Sirupsen/logrus" containerd "github.com/docker/containerd/api/grpc/types" "github.com/docker/docker/pkg/locker" - sysinfo "github.com/docker/docker/pkg/system" - "github.com/docker/docker/utils" + "github.com/docker/docker/pkg/system" "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/timestamp" "golang.org/x/net/context" @@ -81,7 +80,7 @@ func New(stateDir string, options ...RemoteOption) (_ Remote, err error) { } } - if err := sysinfo.MkdirAll(stateDir, 0700); err != nil { + if err := system.MkdirAll(stateDir, 0700); err != nil { return nil, err } @@ -164,8 +163,8 @@ func (r *remote) handleConnectionChange() { transientFailureCount++ if transientFailureCount >= maxConnectionRetryCount { transientFailureCount = 0 - if utils.IsProcessAlive(r.daemonPid) { - utils.KillProcess(r.daemonPid) + if system.IsProcessAlive(r.daemonPid) { + system.KillProcess(r.daemonPid) } <-r.daemonWaitCh if err := r.runContainerdDaemon(); err != nil { //FIXME: Handle error @@ -188,13 +187,13 @@ func (r *remote) Cleanup() { // Wait up to 15secs for it to stop for i := time.Duration(0); i < containerdShutdownTimeout; i += time.Second { - if !utils.IsProcessAlive(r.daemonPid) { + if !system.IsProcessAlive(r.daemonPid) { break } time.Sleep(time.Second) } - if utils.IsProcessAlive(r.daemonPid) { + if system.IsProcessAlive(r.daemonPid) { logrus.Warnf("libcontainerd: containerd (%d) didn't stop within 15 secs, killing it\n", r.daemonPid) syscall.Kill(r.daemonPid, syscall.SIGKILL) } @@ -354,7 +353,7 @@ func (r *remote) runContainerdDaemon() error { if err != nil { return err } - if utils.IsProcessAlive(int(pid)) { + if system.IsProcessAlive(int(pid)) { logrus.Infof("libcontainerd: previous instance of containerd still alive (%d)", pid) r.daemonPid = int(pid) return nil @@ -417,11 +416,11 @@ func (r *remote) runContainerdDaemon() error { } logrus.Infof("libcontainerd: new containerd process, pid: %d", cmd.Process.Pid) if err := setOOMScore(cmd.Process.Pid, r.oomScore); err != nil { - utils.KillProcess(cmd.Process.Pid) + system.KillProcess(cmd.Process.Pid) return err } if _, err := f.WriteString(fmt.Sprintf("%d", cmd.Process.Pid)); err != nil { - utils.KillProcess(cmd.Process.Pid) + system.KillProcess(cmd.Process.Pid) return err } diff --git a/utils/process_unix.go b/pkg/system/process_unix.go similarity index 96% rename from utils/process_unix.go rename to pkg/system/process_unix.go index fc0b1c8b74..58411f9541 100644 --- a/utils/process_unix.go +++ b/pkg/system/process_unix.go @@ -1,6 +1,6 @@ // +build linux freebsd solaris -package utils +package system import ( "syscall" diff --git a/utils/process_windows.go b/pkg/system/process_windows.go similarity index 96% rename from utils/process_windows.go rename to pkg/system/process_windows.go index 03cb855197..e8113f97e3 100644 --- a/utils/process_windows.go +++ b/pkg/system/process_windows.go @@ -1,4 +1,4 @@ -package utils +package system // IsProcessAlive returns true if process with a given pid is running. func IsProcessAlive(pid int) bool {