Skip to content

Commit a85fa09

Browse files
fix: correct post-delete finalizer removal when cluster not found (cherry-pick #24415 for 3.0) (#24589)
Signed-off-by: Pavel Aborilov <[email protected]> Co-authored-by: Pavel <[email protected]>
1 parent b729cff commit a85fa09

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

controller/appcontroller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ func (ctrl *ApplicationController) finalizeApplicationDeletion(app *appv1.Applic
12011201
if err != nil {
12021202
logCtx.Warnf("Unable to get destination cluster: %v", err)
12031203
app.UnSetCascadedDeletion()
1204-
app.UnSetPostDeleteFinalizer()
1204+
app.UnSetPostDeleteFinalizerAll()
12051205
if err := ctrl.updateFinalizers(app); err != nil {
12061206
return err
12071207
}

pkg/apis/application/v1alpha1/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3178,6 +3178,14 @@ func (app *Application) SetPostDeleteFinalizer(stage ...string) {
31783178
setFinalizer(&app.ObjectMeta, strings.Join(append([]string{PostDeleteFinalizerName}, stage...), "/"), true)
31793179
}
31803180

3181+
func (app *Application) UnSetPostDeleteFinalizerAll() {
3182+
for _, finalizer := range app.Finalizers {
3183+
if strings.HasPrefix(finalizer, PostDeleteFinalizerName) {
3184+
setFinalizer(&app.ObjectMeta, finalizer, false)
3185+
}
3186+
}
3187+
}
3188+
31813189
func (app *Application) UnSetPostDeleteFinalizer(stage ...string) {
31823190
setFinalizer(&app.ObjectMeta, strings.Join(append([]string{PostDeleteFinalizerName}, stage...), "/"), false)
31833191
}

0 commit comments

Comments
 (0)