Skip to content

Commit

Permalink
fix: Workflow stuck at running when init container failed. Fixes #10045
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
  • Loading branch information
terrytangyuan committed Nov 16, 2022
1 parent 4eb6cb7 commit 8083cba
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions workflow/controller/operator.go
Expand Up @@ -1337,6 +1337,14 @@ func (woc *wfOperationCtx) assessNodeStatus(pod *apiv1.Pod, old *wfv1.NodeStatus
new.Phase = old.Phase
}
}
// If the init container failed, we should mark the node as failed.
for _, c := range pod.Status.InitContainerStatuses {
if c.State.Terminated != nil && int(c.State.Terminated.ExitCode) != 0 {
new.Phase = wfv1.NodeFailed
woc.log.WithField("new.phase", new.Phase).Info("marking node as failed since init container has non-zero exit code")
break
}
}

// if we are transitioning from Pending to a different state, clear out unchanged message
if old.Phase == wfv1.NodePending && new.Phase != wfv1.NodePending && old.Message == new.Message {
Expand Down

0 comments on commit 8083cba

Please sign in to comment.