Skip to content

Commit

Permalink
fix: Do not reset the root node by default. Fixes #13196 (#13198)
Browse files Browse the repository at this point in the history
Signed-off-by: oninowang <[email protected]>
  • Loading branch information
jswxstw authored and Joibel committed Sep 20, 2024
1 parent 77dc368 commit 269b54c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
41 changes: 41 additions & 0 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,47 @@ func (s *CLISuite) TestRetryWorkflowWithContinueOn() {
})
}

func (s *CLISuite) TestRetryWorkflowWithFailedExitHandler() {
var workflowName string
s.Given().
Workflow(`@testdata/retry-workflow-with-failed-exit-handler.yaml`).
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeFailed).
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
workflowName = metadata.Name
assert.Len(t, status.Nodes, 2)
}).
RunCli([]string{"retry", workflowName}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err, output) {
assert.Contains(t, output, "Name:")
assert.Contains(t, output, "Namespace:")
}
})

s.Given().
When().
WaitForWorkflow(fixtures.ToBeCompleted).
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
workflowName = metadata.Name
assert.Equal(t, wfv1.WorkflowFailed, status.Phase)
assert.Len(t, status.Nodes, 2)
}).
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool {
return status.Name == workflowName
}, func(t *testing.T, status *wfv1.NodeStatus, pod *corev1.Pod) {
assert.Equal(t, wfv1.NodeSucceeded, status.Phase)
}).
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool {
return strings.Contains(status.Name, ".onExit")
}, func(t *testing.T, status *wfv1.NodeStatus, pod *corev1.Pod) {
assert.Equal(t, wfv1.NodeFailed, status.Phase)
assert.Contains(t, status.Message, "exit code 1")
})
}

func (s *CLISuite) TestWorkflowStop() {
s.Given().
Workflow("@smoke/basic.yaml").
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/testdata/retry-workflow-with-failed-exit-handler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: retry-workflow-with-failed-exit-handler
spec:
entrypoint: hello
onExit: exit-handler
templates:
- name: hello
container:
image: alpine:3.18
command: [sh, -c]
args: ["echo hello"]
- name: exit-handler
container:
image: alpine:3.18
command: [sh, -c]
args: ["exit 1"]
7 changes: 0 additions & 7 deletions workflow/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,13 +989,6 @@ func FormulateRetryWorkflow(ctx context.Context, wf *wfv1.Workflow, restartSucce
// Do not allow retry of workflows with pods in Running/Pending phase
return nil, nil, errors.InternalErrorf("Workflow cannot be retried with node %s in %s phase", node.Name, node.Phase)
}

if node.Name == wf.ObjectMeta.Name {
log.Debugf("Reset root node: %s", node.Name)
newNode := node.DeepCopy()
newWF.Status.Nodes.Set(newNode.ID, resetNode(*newNode))
continue
}
}

if len(deletedNodes) > 0 {
Expand Down

0 comments on commit 269b54c

Please sign in to comment.