Skip to content

Commit 792c7ec

Browse files
committed
fix: Remove finalizer if affinity group is already deleted on Cloudstack
Upstream PR kubernetes-sigs#340
1 parent a9142d8 commit 792c7ec

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

controllers/cloudstackaffinitygroup_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,14 @@ func (r *CloudStackAGReconciliationRunner) Reconcile() (ctrl.Result, error) {
7878
}
7979

8080
func (r *CloudStackAGReconciliationRunner) ReconcileDelete() (ctrl.Result, error) {
81-
group := &cloud.AffinityGroup{Name: r.ReconciliationSubject.Name}
81+
group := &cloud.AffinityGroup{Name: r.ReconciliationSubject.Spec.Name}
8282
_ = r.CSUser.FetchAffinityGroup(group)
83-
if group.ID == "" { // Affinity group not found, must have been deleted.
83+
// Affinity group not found, must have been deleted.
84+
if group.ID == "" {
85+
// Deleting affinity groups on Cloudstack can return error but succeed in
86+
// deleting the affinity group. Removing finalizer if affinity group is not
87+
// present on Cloudstack ensures affinity group object deletion is not blocked.
88+
controllerutil.RemoveFinalizer(r.ReconciliationSubject, infrav1.AffinityGroupFinalizer)
8489
return ctrl.Result{}, nil
8590
}
8691
if err := r.CSUser.DeleteAffinityGroup(group); err != nil {

0 commit comments

Comments
 (0)