From fb6c3d0b801063851561ae5ae61501fba40169b0 Mon Sep 17 00:00:00 2001 From: shuangkun tian <72060326+shuangkun@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:34:47 +0800 Subject: [PATCH] fix: make sure Finalizers has chance to be removed. Fixes: #12836 (#12831) Signed-off-by: shuangkun --- test/e2e/fixtures/when.go | 1 + workflow/controller/operator.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/test/e2e/fixtures/when.go b/test/e2e/fixtures/when.go index c65b3668e6e7..88dfc134efc0 100644 --- a/test/e2e/fixtures/when.go +++ b/test/e2e/fixtures/when.go @@ -347,6 +347,7 @@ func (w *When) WaitForWorkflowList(listOptions metav1.ListOptions, condition fun return w } } + time.Sleep(time.Second) } } diff --git a/workflow/controller/operator.go b/workflow/controller/operator.go index dd7f8b1fd929..8a425d28d882 100644 --- a/workflow/controller/operator.go +++ b/workflow/controller/operator.go @@ -806,6 +806,10 @@ func (woc *wfOperationCtx) persistUpdates(ctx context.Context) { woc.log.WithError(err).Warn("failed to delete task-results") } } + // If Finalizer exists, requeue to make sure Finalizer can be removed. + if woc.wf.Status.Fulfilled() && len(wf.GetFinalizers()) > 0 { + woc.requeueAfter(5 * time.Second) + } // It is important that we *never* label pods as completed until we successfully updated the workflow // Failing to do so means we can have inconsistent state.