Skip to content

Commit d5f9a81

Browse files
authored
Merge pull request kubernetes#79873 from tedyu/kube-runtime
Set runtimeState when RuntimeReady is not set or false
2 parents f9afe46 + 3865e2b commit d5f9a81

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

pkg/kubelet/kubelet.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,15 +2189,16 @@ func (kl *Kubelet) updateRuntimeUp() {
21892189
// Set nil if the container runtime network is ready.
21902190
kl.runtimeState.setNetworkState(nil)
21912191
}
2192-
// TODO(random-liu): Add runtime error in runtimeState, and update it
2193-
// when runtime is not ready, so that the information in RuntimeReady
2194-
// condition will be propagated to NodeReady condition.
2192+
// information in RuntimeReady condition will be propagated to NodeReady condition.
21952193
runtimeReady := s.GetRuntimeCondition(kubecontainer.RuntimeReady)
21962194
// If RuntimeReady is not set or is false, report an error.
21972195
if runtimeReady == nil || !runtimeReady.Status {
2198-
klog.Errorf("Container runtime not ready: %v", runtimeReady)
2196+
err := fmt.Errorf("Container runtime not ready: %v", runtimeReady)
2197+
klog.Error(err)
2198+
kl.runtimeState.setRuntimeState(err)
21992199
return
22002200
}
2201+
kl.runtimeState.setRuntimeState(nil)
22012202
kl.oneTimeInitializer.Do(kl.initializeRuntimeDependentModules)
22022203
kl.runtimeState.setRuntimeSync(kl.clock.Now())
22032204
}

pkg/kubelet/runtime.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type runtimeState struct {
3030
lastBaseRuntimeSync time.Time
3131
baseRuntimeSyncThreshold time.Duration
3232
networkError error
33+
runtimeError error
3334
storageError error
3435
cidr string
3536
healthChecks []*healthCheck
@@ -62,6 +63,12 @@ func (s *runtimeState) setNetworkState(err error) {
6263
s.networkError = err
6364
}
6465

66+
func (s *runtimeState) setRuntimeState(err error) {
67+
s.Lock()
68+
defer s.Unlock()
69+
s.runtimeError = err
70+
}
71+
6572
func (s *runtimeState) setStorageState(err error) {
6673
s.Lock()
6774
defer s.Unlock()
@@ -94,6 +101,9 @@ func (s *runtimeState) runtimeErrors() error {
94101
errs = append(errs, fmt.Errorf("%s is not healthy: %v", hc.name, err))
95102
}
96103
}
104+
if s.runtimeError != nil {
105+
errs = append(errs, s.runtimeError)
106+
}
97107

98108
return utilerrors.NewAggregate(errs)
99109
}

0 commit comments

Comments
 (0)