Skip to content

Commit f540abb

Browse files
Remove finalizer if affinity group is already deleted on Cloudstack
1 parent 207f0a2 commit f540abb

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
@@ -76,9 +76,14 @@ func (r *CloudStackAGReconciliationRunner) Reconcile() (ctrl.Result, error) {
7676
}
7777

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

0 commit comments

Comments
 (0)