Skip to content

Commit

Permalink
fix: Mark Pending pod nodes as Failed when shutting down. Fixes #…
Browse files Browse the repository at this point in the history
…13210 (#13214)

Signed-off-by: oninowang <oninowang@tencent.com>
Co-authored-by: jswxstw <jswxstw@gmail.com>
(cherry picked from commit 6c33cbb)
  • Loading branch information
jswxstw authored and agilgur5 committed Jul 6, 2024
1 parent d5ab947 commit 981acfe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions workflow/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ spec:
})
expectWorkflow(ctx, controller, "my-wf-2", func(wf *wfv1.Workflow) {
if assert.NotNil(t, wf) {
assert.Equal(t, wfv1.WorkflowSucceeded, wf.Status.Phase)
assert.Equal(t, wfv1.WorkflowFailed, wf.Status.Phase)
}
})
})
Expand Down Expand Up @@ -1162,9 +1162,9 @@ func TestPendingPodWhenTerminate(t *testing.T) {

woc := newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)
assert.Equal(t, wfv1.WorkflowSucceeded, woc.wf.Status.Phase)
assert.Equal(t, wfv1.WorkflowFailed, woc.wf.Status.Phase)
for _, node := range woc.wf.Status.Nodes {
assert.Equal(t, wfv1.NodeSkipped, node.Phase)
assert.Equal(t, wfv1.NodeFailed, node.Phase)
}
}

Expand Down
2 changes: 1 addition & 1 deletion workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6853,7 +6853,7 @@ func TestNoPodsWhenShutdown(t *testing.T) {

node := woc.wf.Status.Nodes.FindByDisplayName("hello-world")
if assert.NotNil(t, node) {
assert.Equal(t, wfv1.NodeSkipped, node.Phase)
assert.Equal(t, wfv1.NodeFailed, node.Phase)
assert.Contains(t, node.Message, "workflow shutdown with strategy: Stop")
}
}
Expand Down
2 changes: 1 addition & 1 deletion workflow/controller/workflowpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (woc *wfOperationCtx) createWorkflowPod(ctx context.Context, nodeName strin

if !woc.GetShutdownStrategy().ShouldExecute(opts.onExitPod) {
// Do not create pods if we are shutting down
woc.markNodePhase(nodeName, wfv1.NodeSkipped, fmt.Sprintf("workflow shutdown with strategy: %s", woc.GetShutdownStrategy()))
woc.markNodePhase(nodeName, wfv1.NodeFailed, fmt.Sprintf("workflow shutdown with strategy: %s", woc.GetShutdownStrategy()))
return nil, nil
}

Expand Down

0 comments on commit 981acfe

Please sign in to comment.