Skip to content

Commit

Permalink
fix: Remove finalizer if affinity group is already deleted on Cloudstack
Browse files Browse the repository at this point in the history
  • Loading branch information
hrak committed May 15, 2024
1 parent a9142d8 commit 792c7ec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions controllers/cloudstackaffinitygroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ func (r *CloudStackAGReconciliationRunner) Reconcile() (ctrl.Result, error) {
}

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

0 comments on commit 792c7ec

Please sign in to comment.