Commit ca84aae4 authored by Victor Marmol's avatar Victor Marmol

Kubelet: wait up to 5m for Docker to come up.

The Kubelet assumes Docker is running during its execution and on machine boot it is a race between Docker coming up and Kubelet calling Docker. This PR waits for Docker to be up before the Kubelet begins doing useful work. On timeout, Kubelet exits and expects to be restarted.
parent ee1e40d4
...@@ -52,14 +52,19 @@ import ( ...@@ -52,14 +52,19 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
) )
// taken from lmctfy https://github.com/google/lmctfy/blob/master/lmctfy/controllers/cpu_controller.cc const (
const minShares = 2 // taken from lmctfy https://github.com/google/lmctfy/blob/master/lmctfy/controllers/cpu_controller.cc
const sharesPerCPU = 1024 minShares = 2
const milliCPUToCPU = 1000 sharesPerCPU = 1024
milliCPUToCPU = 1000
// The oom_score_adj of the POD infrastructure container. The default is 0, so
// any value below that makes it *less* likely to get OOM killed.
podOomScoreAdj = -100
// The oom_score_adj of the POD infrastructure container. The default is 0, so // Max amount of time to wait for the Docker daemon to come up.
// any value below that makes it *less* likely to get OOM killed. maxWaitForDocker = 5 * time.Minute
const podOomScoreAdj = -100 )
// SyncHandler is an interface implemented by Kubelet, for testability // SyncHandler is an interface implemented by Kubelet, for testability
type SyncHandler interface { type SyncHandler interface {
...@@ -103,6 +108,22 @@ func NewMainKubelet( ...@@ -103,6 +108,22 @@ func NewMainKubelet(
return nil, fmt.Errorf("invalid minimum GC age %d", minimumGCAge) return nil, fmt.Errorf("invalid minimum GC age %d", minimumGCAge)
} }
// Wait for the Docker daemon to be up (with a timeout).
waitStart := time.Now()
dockerUp := false
for time.Since(waitStart) < maxWaitForDocker {
_, err := dockerClient.Version()
if err == nil {
dockerUp = true
break
}
time.Sleep(100 * time.Millisecond)
}
if !dockerUp {
return nil, fmt.Errorf("timed out waiting for Docker to come up")
}
serviceStore := cache.NewStore(cache.MetaNamespaceKeyFunc) serviceStore := cache.NewStore(cache.MetaNamespaceKeyFunc)
if kubeClient != nil { if kubeClient != nil {
// TODO: cache.NewListWatchFromClient is limited as it takes a client implementation rather // TODO: cache.NewListWatchFromClient is limited as it takes a client implementation rather
......
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