Skip to content

Ensure there is a finalizer on applicationSet when deletionOrder is set to Reverse #25105

@ranakan19

Description

@ranakan19

Summary

Ensure there is a finalizer on applicationSet when deletionOrder is set to Reverse

Motivation

By default background deletion is performed, but when deletionOrder is set to reverse, for controlled deletion applicationset needs to be deleted last. At present performReverseDeletion is reached only when the applicationSet has a finalizer added when created, but if users miss to add this finalizer then reverse deletion does not happen as expected. ref - slack thread
Ensuring that any ApplicationSet configured for reverse deletion will have the necessary finalizer to enable the controlled deletion sequence when the ApplicationSet is eventually deleted is a better user experience.

Proposal

Before generators, ensure finalizer exists or add if missing:

if isProgressiveSyncDeletionOrderReversed(&applicationSetInfo) {
      if !controllerutil.ContainsFinalizer(&applicationSetInfo, argov1alpha1.ResourcesFinalizerName) {
          controllerutil.AddFinalizer(&applicationSetInfo, argov1alpha1.ResourcesFinalizerName)
          if err := r.Update(ctx, &applicationSetInfo); err != nil {
              return ctrl.Result{}, err
          }
          logCtx.Infof("Added resources finalizer to ApplicationSet %s for reverse deletion", applicationSetInfo.Name)
          // Requeue to continue with updated resource
          return ctrl.Result{RequeueAfter: requeueAfter,}, nil
      }
  }

Metadata

Metadata

Labels

enhancementNew feature or requestfeature:progressive-syncIssues related to the ApplicationSet progressive sync feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions