Skip to content

Commit

Permalink
fix(controller): Lock nodes in pod reconciliation. Fixes #5979 (#5982)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec authored May 24, 2021
1 parent 60b6b5c commit 46dcaea
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions workflow/controller/exec_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func (woc *wfOperationCtx) applyExecutionControl(ctx context.Context, pod *apiv1
err := woc.controller.kubeclientset.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{})
if err == nil {
wfNodesLock.Lock()
defer wfNodesLock.Unlock()
node := woc.wf.Status.Nodes[pod.Name]
wfNodesLock.Unlock()
woc.markNodePhase(node.Name, wfv1.NodeFailed, fmt.Sprintf("workflow shutdown with strategy: %s", woc.GetShutdownStrategy()))
return nil
}
Expand All @@ -55,8 +55,8 @@ func (woc *wfOperationCtx) applyExecutionControl(ctx context.Context, pod *apiv1
err := woc.controller.kubeclientset.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{})
if err == nil {
wfNodesLock.Lock()
defer wfNodesLock.Unlock()
node := woc.wf.Status.Nodes[pod.Name]
wfNodesLock.Unlock()
woc.markNodePhase(node.Name, wfv1.NodeFailed, "Step exceeded its deadline")
return nil
}
Expand All @@ -74,7 +74,10 @@ func (woc *wfOperationCtx) applyExecutionControl(ctx context.Context, pod *apiv1
}
}

for _, c := range woc.findTemplate(pod).GetMainContainerNames() {
wfNodesLock.Lock()
template := woc.findTemplate(pod)
wfNodesLock.Unlock()
for _, c := range template.GetMainContainerNames() {
if woc.GetShutdownStrategy().Enabled() {
if _, onExitPod := pod.Labels[common.LabelKeyOnExit]; !woc.GetShutdownStrategy().ShouldExecute(onExitPod) {
podExecCtl.Deadline = &time.Time{}
Expand Down

0 comments on commit 46dcaea

Please sign in to comment.