Skip to content

Commit

Permalink
handle cluster cascading deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Dec 13, 2023
1 parent 7273c29 commit 8726281
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions controller/pkg/cluster_controller/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,17 @@ func (r *Reconciler) getProviderIdAndSetControllerRef(ctx context.Context, clust
return nil, &ctrl.Result{}, fmt.Errorf("could not get provider, got error: %+v", err)
}

// Once provider is marked with deletion timestamp we should delete cluster as well.
// Provider cannot be deleted until cluster exists so that ensures cascading deletion.
if provider.DeletionTimestamp != nil {
err := r.Delete(ctx, cluster)
if err != nil {
return nil, &ctrl.Result{}, err
}

return nil, &requeue, nil
}

if !provider.Status.HasID() {
logger.Info("Provider does not have ID set yet")
return nil, &requeue, nil
Expand Down

0 comments on commit 8726281

Please sign in to comment.