Skip to content

Commit

Permalink
fix: workflows that have not completed due to a retry operation shoul…
Browse files Browse the repository at this point in the history
…d not be deleted (Fixes argoproj#12636)
  • Loading branch information
siwet committed Apr 6, 2024
1 parent 748ae47 commit 8a5ec81
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion workflow/gccontroller/gc_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,24 @@ 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 to fix retry-with-ttl bug (#12626).
wf, err := c.wfclientset.ArgoprojV1alpha1().Workflows(namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
if apierr.IsNotFound(err) {
log.Infof("Workflow already deleted '%s'", key)
return nil
} else {
return err
}
}
if !(wf.Status.Failed() || wf.Status.Successful() || wf.Status.Phase.Completed()) {
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

0 comments on commit 8a5ec81

Please sign in to comment.