Skip to content

Commit 3865e2b

Browse files
tedyuyutedz
authored andcommitted
Set runtimeState when RuntimeReady is not set or false
1 parent 656cf9c commit 3865e2b

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
@@ -2182,15 +2182,16 @@ func (kl *Kubelet) updateRuntimeUp() {
21822182
// Set nil if the container runtime network is ready.
21832183
kl.runtimeState.setNetworkState(nil)
21842184
}
2185-
// TODO(random-liu): Add runtime error in runtimeState, and update it
2186-
// when runtime is not ready, so that the information in RuntimeReady
2187-
// condition will be propagated to NodeReady condition.
2185+
// information in RuntimeReady condition will be propagated to NodeReady condition.
21882186
runtimeReady := s.GetRuntimeCondition(kubecontainer.RuntimeReady)
21892187
// If RuntimeReady is not set or is false, report an error.
21902188
if runtimeReady == nil || !runtimeReady.Status {
2191-
klog.Errorf("Container runtime not ready: %v", runtimeReady)
2189+
err := fmt.Errorf("Container runtime not ready: %v", runtimeReady)
2190+
klog.Error(err)
2191+
kl.runtimeState.setRuntimeState(err)
21922192
return
21932193
}
2194+
kl.runtimeState.setRuntimeState(nil)
21942195
kl.oneTimeInitializer.Do(kl.initializeRuntimeDependentModules)
21952196
kl.runtimeState.setRuntimeSync(kl.clock.Now())
21962197
}

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)