diff --git a/pkg/kubelet/cm/BUILD b/pkg/kubelet/cm/BUILD index 200b2ade67..749dd2fae1 100644 --- a/pkg/kubelet/cm/BUILD +++ b/pkg/kubelet/cm/BUILD @@ -46,7 +46,6 @@ go_library( "//vendor:k8s.io/apimachinery/pkg/api/resource", "//vendor:k8s.io/apimachinery/pkg/types", "//vendor:k8s.io/apimachinery/pkg/util/errors", - "//vendor:k8s.io/apimachinery/pkg/util/runtime", "//vendor:k8s.io/apimachinery/pkg/util/sets", "//vendor:k8s.io/apimachinery/pkg/util/wait", "//vendor:k8s.io/client-go/tools/record", diff --git a/pkg/kubelet/cm/container_manager_linux.go b/pkg/kubelet/cm/container_manager_linux.go index 39b377ac0f..52f9f32fc0 100644 --- a/pkg/kubelet/cm/container_manager_linux.go +++ b/pkg/kubelet/cm/container_manager_linux.go @@ -35,7 +35,6 @@ import ( "github.com/opencontainers/runc/libcontainer/configs" "k8s.io/apimachinery/pkg/api/resource" utilerrors "k8s.io/apimachinery/pkg/util/errors" - "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/tools/record" @@ -630,15 +629,25 @@ func getPidFromPidFile(pidFile string) (int, error) { } func getPidsForProcess(name, pidFile string) ([]int, error) { - if len(pidFile) > 0 { - if pid, err := getPidFromPidFile(pidFile); err == nil { - return []int{pid}, nil - } else { - // log the error and fall back to pidof - runtime.HandleError(err) - } + if len(pidFile) == 0 { + return procfs.PidOf(name) } - return procfs.PidOf(name) + + pid, err := getPidFromPidFile(pidFile) + if err == nil { + return []int{pid}, nil + } + + // Try to lookup pid by process name + pids, err2 := procfs.PidOf(name) + if err2 == nil { + return pids, nil + } + + // Return error from getPidFromPidFile since that should have worked + // and is the real source of the problem. + glog.V(4).Infof("unable to get pid from %s: %v", pidFile, err) + return []int{}, err } // Ensures that the Docker daemon is in the desired container.