Commit d42d630d authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #43762 from sjenning/docker-pid-fail

Automatic merge from submit-queue refactor getPidsForProcess and change error handling xref https://github.com/openshift/origin/issues/13262 Right now, failure to read the docker pid from the pid file results in some premature nasty logging. There is still a chance we can get the docker pid from `procfs.PidOf()`. If that fails we should just log at `V(4)` rather than `runtime.HanldeError()`. This PR refactors `getPidsForProcess()` to wait until both methods for determining the pid fail before logging anything. @smarterclayton @ncdc @derekwaynecarr
parents 63872a09 ebb1243a
...@@ -46,7 +46,6 @@ go_library( ...@@ -46,7 +46,6 @@ go_library(
"//vendor:k8s.io/apimachinery/pkg/api/resource", "//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/types", "//vendor:k8s.io/apimachinery/pkg/types",
"//vendor:k8s.io/apimachinery/pkg/util/errors", "//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/sets",
"//vendor:k8s.io/apimachinery/pkg/util/wait", "//vendor:k8s.io/apimachinery/pkg/util/wait",
"//vendor:k8s.io/client-go/tools/record", "//vendor:k8s.io/client-go/tools/record",
......
...@@ -35,7 +35,6 @@ import ( ...@@ -35,7 +35,6 @@ import (
"github.com/opencontainers/runc/libcontainer/configs" "github.com/opencontainers/runc/libcontainer/configs"
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
utilerrors "k8s.io/apimachinery/pkg/util/errors" utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/record" "k8s.io/client-go/tools/record"
...@@ -630,15 +629,25 @@ func getPidFromPidFile(pidFile string) (int, error) { ...@@ -630,15 +629,25 @@ func getPidFromPidFile(pidFile string) (int, error) {
} }
func getPidsForProcess(name, pidFile string) ([]int, error) { func getPidsForProcess(name, pidFile string) ([]int, error) {
if len(pidFile) > 0 { if len(pidFile) == 0 {
if pid, err := getPidFromPidFile(pidFile); err == nil { return procfs.PidOf(name)
}
pid, err := getPidFromPidFile(pidFile)
if err == nil {
return []int{pid}, nil return []int{pid}, nil
} else {
// log the error and fall back to pidof
runtime.HandleError(err)
} }
// Try to lookup pid by process name
pids, err2 := procfs.PidOf(name)
if err2 == nil {
return pids, nil
} }
return procfs.PidOf(name)
// 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. // Ensures that the Docker daemon is in the desired container.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment