File tree Expand file tree Collapse file tree 1 file changed +30
-4
lines changed
Expand file tree Collapse file tree 1 file changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -203,13 +203,39 @@ impl HttpK8sClient {
203203 return false ;
204204 } ;
205205
206- // Check last terminated state for non-zero exit code
207- if let Some ( last_state) = & container_status. last_state
208- && let Some ( terminated) = & last_state. terminated
209- {
206+ let Some ( state) = & container_status. state else {
207+ return false ;
208+ } ;
209+
210+ // Currently terminated with non-zero exit code.
211+ if let Some ( terminated) = & state. terminated {
210212 return terminated. exit_code != 0 ;
211213 }
212214
215+ // Waiting state, we want to distinguish normal waiting reasons from abnormal ones.
216+ if let Some ( waiting) = & state. waiting {
217+ if let Some ( reason) = & waiting. reason {
218+ match reason. as_str ( ) {
219+ // Crash/restart errors
220+ "CrashLoopBackOff" => return true ,
221+
222+ // Image-related errors (6 predefined in kubelet)
223+ "ImagePullBackOff"
224+ | "ErrImagePull"
225+ | "ErrImageNeverPull"
226+ | "InvalidImageName"
227+ | "ImageInspectError"
228+ | "RegistryUnavailable" => return true ,
229+
230+ // Container creation errors
231+ "CreateContainerConfigError" | "CreateContainerError" | "RunContainerError" => {
232+ return true ;
233+ }
234+ _ => { }
235+ }
236+ }
237+ }
238+
213239 false
214240 }
215241}
You can’t perform that action at this time.
0 commit comments