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: workflows that are retrying should not be deleted (Fixes #12636) #12905

Merged
merged 1 commit into from
Apr 13, 2024
Merged
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
15 changes: 14 additions & 1 deletion workflow/gccontroller/gc_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,22 @@ func (c *Controller) deleteWorkflow(ctx context.Context, key string) error {
// It should be impossible for a workflow to have been queue without a valid key.
namespace, name, _ := cache.SplitMetaNamespaceKey(key)

// Double check that this workflow is still completed. If it were retried, it may be running again (c.f. https://github.com/argoproj/argo-workflows/issues/12636)
obj, exists, err := c.wfInformer.GetStore().GetByKey(key)
if err != nil {
return nil
}
if exists {
un, ok := obj.(*unstructured.Unstructured)
if ok && !common.IsDone(un) {
log.Infof("Workflow '%s' is not completed due to a retry operation, ignore deletion", key)
return nil
}
}

// Any workflow that was queued must need deleting, therefore we do not check the expiry again.
log.Infof("Deleting garbage collected workflow '%s'", key)
err := c.wfclientset.ArgoprojV1alpha1().Workflows(namespace).Delete(ctx, name, metav1.DeleteOptions{PropagationPolicy: commonutil.GetDeletePropagation()})
err = c.wfclientset.ArgoprojV1alpha1().Workflows(namespace).Delete(ctx, name, metav1.DeleteOptions{PropagationPolicy: commonutil.GetDeletePropagation()})
if err != nil {
if apierr.IsNotFound(err) {
log.Infof("Workflow already deleted '%s'", key)
Expand Down