Skip to content

Commit

Permalink
fix: Only cleanup agent pod if exists. Fixes #12659 (#13294)
Browse files Browse the repository at this point in the history
Signed-off-by: oninowang <[email protected]>
Signed-off-by: jswxstw <[email protected]>
Co-authored-by: jswxstw <[email protected]>
  • Loading branch information
jswxstw and jswxstw committed Jul 2, 2024
1 parent 3f9b992 commit 825aacf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 0 additions & 4 deletions workflow/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,6 @@ spec:

woc.operate(ctx)
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.Equal(t, wfv1.WorkflowSucceeded, woc.wf.Status.Phase)
podCleanupKey := "test/my-wf/labelPodCompleted"
assert.Equal(t, 0, controller.podCleanupQueue.NumRequeues(podCleanupKey))
Expand Down Expand Up @@ -1174,7 +1173,6 @@ spec:
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.Equal(t, wfv1.WorkflowFailed, woc.wf.Status.Phase)
pods, err := listPods(woc)
assert.NoError(t, err)
Expand Down Expand Up @@ -1215,7 +1213,6 @@ func TestWorkflowReferItselfFromExpression(t *testing.T) {

woc.operate(ctx)
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.Equal(t, wfv1.WorkflowSucceeded, woc.wf.Status.Phase)
}

Expand Down Expand Up @@ -1253,6 +1250,5 @@ func TestWorkflowWithLongArguments(t *testing.T) {

woc.operate(ctx)
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.True(t, controller.processNextPodCleanupItem(ctx))
assert.Equal(t, wfv1.WorkflowSucceeded, woc.wf.Status.Phase)
}
4 changes: 3 additions & 1 deletion workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,9 @@ func (woc *wfOperationCtx) markWorkflowPhase(ctx context.Context, phase wfv1.Wor
}
}
woc.updated = true
woc.controller.queuePodForCleanup(woc.wf.Namespace, woc.getAgentPodName(), deletePod)
if woc.hasTaskSetNodes() {
woc.controller.queuePodForCleanup(woc.wf.Namespace, woc.getAgentPodName(), deletePod)
}
}
}

Expand Down

0 comments on commit 825aacf

Please sign in to comment.