mirror of
https://github.com/actions-runner-controller/actions-runner-controller.git
synced 2026-09-30 11:12:12 +02:00
Fix: Detect init container failure in EphemeralRunner controller (#4457)
This commit is contained in:
@@ -351,6 +351,12 @@ func (r *EphemeralRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
|
||||
)
|
||||
return ctrl.Result{}, r.deleteEphemeralRunnerOrPod(ctx, ephemeralRunner, pod, log)
|
||||
|
||||
case initContainerFailed(pod):
|
||||
log.Info("Pod has a failed init container, deleting pod as failed so it can be restarted",
|
||||
"initContainerStatuses", pod.Status.InitContainerStatuses,
|
||||
)
|
||||
return ctrl.Result{}, r.deleteEphemeralRunnerOrPod(ctx, ephemeralRunner, pod, log)
|
||||
|
||||
case cs == nil:
|
||||
// starting, no container state yet
|
||||
log.Info("Waiting for runner container status to be available")
|
||||
@@ -862,3 +868,13 @@ func runnerContainerStatus(pod *corev1.Pod) *corev1.ContainerStatus {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func initContainerFailed(pod *corev1.Pod) bool {
|
||||
for i := range pod.Status.InitContainerStatuses {
|
||||
cs := &pod.Status.InitContainerStatuses[i]
|
||||
if cs.State.Terminated != nil && cs.State.Terminated.ExitCode != 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user