Skip to content

Commit

Permalink
Delete VNet before deleting group (#263)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Chen <[email protected]>
  • Loading branch information
mchen727 and Matthew Chen authored Mar 20, 2024
1 parent e77ad50 commit 7f64d35
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions controllers/azurestackhcicluster_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,6 @@ func (r *azureStackHCIClusterReconciler) Delete() error {
}
}

groupSpec := &groups.Spec{
Name: r.scope.GetResourceGroup(),
Location: r.scope.Location(),
}

// a group is deleted only if it was created by azureStackHCIClusterReconciler
// which has tag "ownedBy: caph"
if err := r.groupSvc.Delete(r.scope.Context, groupSpec); err != nil {
return errors.Wrapf(err, "failed to delete group %s for cluster %s", r.scope.GetResourceGroup(), r.scope.Name())
}

vnetSpec := &virtualnetworks.Spec{
Name: r.scope.Vnet().Name,
CIDR: azurestackhci.DefaultVnetCIDR,
Expand All @@ -127,6 +116,17 @@ func (r *azureStackHCIClusterReconciler) Delete() error {
}
}

groupSpec := &groups.Spec{
Name: r.scope.GetResourceGroup(),
Location: r.scope.Location(),
}

// a group is deleted only if it was created by azureStackHCIClusterReconciler
// which has tag "ownedBy: caph"
if err := r.groupSvc.Delete(r.scope.Context, groupSpec); err != nil {
return errors.Wrapf(err, "failed to delete group %s for cluster %s", r.scope.GetResourceGroup(), r.scope.Name())
}

return nil
}

Expand Down

0 comments on commit 7f64d35

Please sign in to comment.