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
- merge conflicts with tests removed in backport by agilgur5

Signed-off-by: oninowang <oninowang@tencent.com>
Signed-off-by: jswxstw <jswxstw@gmail.com>
Co-authored-by: jswxstw <jswxstw@gmail.com>
Co-authored-by: agilgur5 <agilgur5@gmail.com>
(cherry picked from commit 825aacf)
  • Loading branch information
jswxstw authored and agilgur5 committed Jul 25, 2024
1 parent 4304905 commit f19d6d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions workflow/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,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 @@ -1147,7 +1146,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 @@ -1188,6 +1186,5 @@ 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)
}
4 changes: 3 additions & 1 deletion workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2395,7 +2395,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 f19d6d6

Please sign in to comment.