Skip to content

Commit

Permalink
Merge pull request #766 from yastij/cherrypick-delete-vspherecluster
Browse files Browse the repository at this point in the history
cherry-pick of #763: check that vspheremachines are deleted before deleting the vspherecluster
  • Loading branch information
k8s-ci-robot authored Feb 21, 2020
2 parents 9825ad5 + 621fb1f commit 6b3cbc7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controllers/vspherecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ func (r clusterReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr er
func (r clusterReconciler) reconcileDelete(ctx *context.ClusterContext) (reconcile.Result, error) {
ctx.Logger.Info("Reconciling VSphereCluster delete")

vsphereMachines, err := infrautilv1.GetVSphereMachinesInCluster(ctx, ctx.Client, ctx.VSphereCluster.Namespace, ctx.VSphereCluster.Name)
if err != nil {
return reconcile.Result{}, errors.Wrapf(err,
"unable to list VSphereMachines part of VSphereCluster %s/%s", ctx.VSphereCluster.Namespace, ctx.VSphereCluster.Name)
}

if len(vsphereMachines) > 0 {
return reconcile.Result{}, errors.Errorf("unable to delete VSphereCluster %s/%s: %v VSphereMachines left", ctx.VSphereCluster.Namespace, ctx.VSphereCluster.Name, len(vsphereMachines))
}

// Cluster is deleted so remove the finalizer.
ctx.VSphereCluster.Finalizers = clusterutilv1.Filter(ctx.VSphereCluster.Finalizers, infrav1.ClusterFinalizer)

Expand Down

0 comments on commit 6b3cbc7

Please sign in to comment.