Skip to content

Commit

Permalink
fix: delete skipped node when resubmit.Fixes: argoproj#12936
Browse files Browse the repository at this point in the history
Signed-off-by: shuangkun <tsk2013uestc@163.com>
  • Loading branch information
shuangkun committed Apr 15, 2024
1 parent ea5410a commit 832c628
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,64 @@ func (s *CLISuite) TestWorkflowResubmit() {
})
}

func (s *CLISuite) TestWorkflowResubmitDAGWithDependencies() {
var wfString string
s.Given().
Workflow("@testdata/resubmit-dag-with-dependencies.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeFailed).
Then().
RunCli([]string{"resubmit", "--memoized", "@latest"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err) {
assert.Contains(t, output, "Name:")
assert.Contains(t, output, "Namespace:")
assert.Contains(t, output, "ServiceAccount:")
assert.Contains(t, output, "Status:")
assert.Contains(t, output, "Created:")
}
}).
RunCli([]string{"get", "@latest", "-o", "yaml"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err) {
wfString = output
}
})

s.Given().
Workflow(wfString).
When().
WaitForWorkflow(fixtures.ToBeCompleted).
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowFailed, status.Phase)
assert.Equal(t, 5, len(status.Nodes))
}).
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool {
return strings.Contains(status.Name, ".A")
}, func(t *testing.T, status *wfv1.NodeStatus, pod *corev1.Pod) {
assert.Equal(t, wfv1.NodeTypeSkipped, status.Type)
assert.Contains(t, status.Message, "original pod")
}).
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool {
return strings.Contains(status.Name, ".B")
}, 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")
}).
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool {
return strings.Contains(status.Name, ".C")
}, func(t *testing.T, status *wfv1.NodeStatus, pod *corev1.Pod) {
assert.Equal(t, wfv1.NodeTypeSkipped, status.Type)
assert.Contains(t, status.Message, "omitted: depends condition not met")
}).
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool {
return strings.Contains(status.Name, ".D")
}, func(t *testing.T, status *wfv1.NodeStatus, pod *corev1.Pod) {
assert.Equal(t, wfv1.NodeTypeSkipped, status.Type)
assert.Contains(t, status.Message, "omitted: depends condition not met")
})
}

func (s *CLISuite) TestWorkflowResubmitByLabelSelector() {
s.Given().
Workflow("@testdata/exit-1.yaml").
Expand Down
35 changes: 35 additions & 0 deletions test/e2e/testdata/resubmit-dag-with-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: resubmit-dag-with-dependencies-
labels:
workflow: resubmit-dag-with-dependencies
spec:
entrypoint: rand-fail-dag
templates:
- name: rand-fail-dag
dag:
tasks:
- name: A
template: success
- name: B
template: fail
depends: A
- name: C
depends: "B"
template: success
- name: D
depends: "C"
template: success
- name: fail
container:
image: busybox
command: ["sh", -c]
args:
- exit 1
- name: success
container:
image: busybox
command: ["sh", -c]
args:
- exit 0
3 changes: 3 additions & 0 deletions workflow/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,9 @@ func FormulateResubmitWorkflow(ctx context.Context, wf *wfv1.Workflow, memoized
newNode.Phase = wfv1.NodeSkipped
newNode.Type = wfv1.NodeTypeSkipped
newNode.Message = fmt.Sprintf("original pod: %s", originalID)
} else if newNode.Type == wfv1.NodeTypeSkipped && !isDescendantNodeSucceeded(wf, node, make(map[string]bool)) {
newWF.Status.Nodes.Delete(newNode.ID)
continue
} else {
newNode.Phase = wfv1.NodePending
newNode.Message = ""
Expand Down

0 comments on commit 832c628

Please sign in to comment.