Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete skipped node when resubmit with memoized.Fixes: #12936 #12940

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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