From d79b9ea9a7797d7911fcf658031e38908a5c8c2f Mon Sep 17 00:00:00 2001 From: jswxstw <385920199@qq.com> Date: Mon, 24 Jun 2024 00:59:39 +0800 Subject: [PATCH] fix: Mark `Pending` pod nodes as `Failed` when shutting down. Fixes #13210 (#13214) Signed-off-by: oninowang Co-authored-by: jswxstw (cherry picked from commit 6c33cbbdb3258d53095f8334375f4a18a4c48044) --- workflow/controller/controller_test.go | 6 +++--- workflow/controller/operator_test.go | 2 +- workflow/controller/workflowpod.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/workflow/controller/controller_test.go b/workflow/controller/controller_test.go index 96bb7d703496..24600050a59e 100644 --- a/workflow/controller/controller_test.go +++ b/workflow/controller/controller_test.go @@ -697,7 +697,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) } }) }) @@ -1167,9 +1167,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) } } diff --git a/workflow/controller/operator_test.go b/workflow/controller/operator_test.go index 5d220bd4faef..b6f2b6e750fd 100644 --- a/workflow/controller/operator_test.go +++ b/workflow/controller/operator_test.go @@ -7623,7 +7623,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") } } diff --git a/workflow/controller/workflowpod.go b/workflow/controller/workflowpod.go index d4819d17bf9c..e941ff6a8d4f 100644 --- a/workflow/controller/workflowpod.go +++ b/workflow/controller/workflowpod.go @@ -93,7 +93,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 }