mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
Merge pull request #5187 from vmarmol/wait-docker
Kubelet: wait up to 5m for Docker to come up.
This commit is contained in:
commit
77546692a7
@ -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
|
// 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.
|
// any value below that makes it *less* likely to get OOM killed.
|
||||||
const podOomScoreAdj = -100
|
podOomScoreAdj = -100
|
||||||
|
|
||||||
|
// Max amount of time to wait for the Docker daemon to come up.
|
||||||
|
maxWaitForDocker = 5 * time.Minute
|
||||||
|
)
|
||||||
|
|
||||||
// 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(
|
|||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user