Skip to content

Commit e10f85c

Browse files
authored
ref(api): Refine logic for determining pipeline state (#489)
1 parent eeef10c commit e10f85c

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

etl-api/src/k8s/http.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)