Skip to content

Commit

Permalink
fix: mark ImageJob as failed when OOM (eraser-dev#837)
Browse files Browse the repository at this point in the history
Signed-off-by: ashnamehrotra <[email protected]>
  • Loading branch information
ashnamehrotra committed Aug 29, 2023
1 parent bbaf0b3 commit a026f56
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion controllers/imagejob/imagejob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ func (r *Reconciler) handleNewJob(ctx context.Context, imageJob *eraserv1.ImageJ
if err != nil {
return err
}

log.Info("Started "+containerName+" pod on node", "nodeName", nodeName)
namespacedNames = append(namespacedNames, types.NamespacedName{Name: pod.Name, Namespace: pod.Namespace})
}
Expand Down Expand Up @@ -455,12 +456,22 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
func podsComplete(podList []corev1.Pod) bool {
for i := range podList {
if podList[i].Status.Phase == corev1.PodRunning || podList[i].Status.Phase == corev1.PodPending {
return false
return containersFailed(&podList[i])
}
}
return true
}

func containersFailed(pod *corev1.Pod) bool {
statuses := pod.Status.ContainerStatuses
for i := range statuses {
if statuses[i].State.Terminated != nil && statuses[i].State.Terminated.ExitCode != 0 {
return true
}
}
return false
}

func (r *Reconciler) updateJobStatus(ctx context.Context, imageJob *eraserv1.ImageJob) error {
if imageJob.Name != "" {
if err := r.Status().Update(ctx, imageJob); err != nil {
Expand Down

0 comments on commit a026f56

Please sign in to comment.