Merge pull request #79873 from tedyu/kube-runtime

Set runtimeState when RuntimeReady is not set or false
This commit is contained in:
Kubernetes Prow Robot 2019-08-23 17:58:37 -07:00 committed by GitHub
commit d5f9a81d0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -2189,15 +2189,16 @@ func (kl *Kubelet) updateRuntimeUp() {
// Set nil if the container runtime network is ready.
kl.runtimeState.setNetworkState(nil)
}
// TODO(random-liu): Add runtime error in runtimeState, and update it
// when runtime is not ready, so that the information in RuntimeReady
// condition will be propagated to NodeReady condition.
// information in RuntimeReady condition will be propagated to NodeReady condition.
runtimeReady := s.GetRuntimeCondition(kubecontainer.RuntimeReady)
// If RuntimeReady is not set or is false, report an error.
if runtimeReady == nil || !runtimeReady.Status {
klog.Errorf("Container runtime not ready: %v", runtimeReady)
err := fmt.Errorf("Container runtime not ready: %v", runtimeReady)
klog.Error(err)
kl.runtimeState.setRuntimeState(err)
return
}
kl.runtimeState.setRuntimeState(nil)
kl.oneTimeInitializer.Do(kl.initializeRuntimeDependentModules)
kl.runtimeState.setRuntimeSync(kl.clock.Now())
}

View File

@ -30,6 +30,7 @@ type runtimeState struct {
lastBaseRuntimeSync time.Time
baseRuntimeSyncThreshold time.Duration
networkError error
runtimeError error
storageError error
cidr string
healthChecks []*healthCheck
@ -62,6 +63,12 @@ func (s *runtimeState) setNetworkState(err error) {
s.networkError = err
}
func (s *runtimeState) setRuntimeState(err error) {
s.Lock()
defer s.Unlock()
s.runtimeError = err
}
func (s *runtimeState) setStorageState(err error) {
s.Lock()
defer s.Unlock()
@ -94,6 +101,9 @@ func (s *runtimeState) runtimeErrors() error {
errs = append(errs, fmt.Errorf("%s is not healthy: %v", hc.name, err))
}
}
if s.runtimeError != nil {
errs = append(errs, s.runtimeError)
}
return utilerrors.NewAggregate(errs)
}