Skip to content

Commit

Permalink
fix cluster deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
zreigz committed May 9, 2024
1 parent 58c50bd commit 1647c3d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controller/internal/controller/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (r *ClusterReconciler) Reconcile(ctx context.Context, req reconcile.Request

// Get Provider ID from the reference if it is set and ensure that controller reference is set properly.
providerId, result, err := r.getProviderIdAndSetControllerRef(ctx, cluster)
if result != nil {
if result != nil || err != nil {
utils.MarkCondition(cluster.SetCondition, v1alpha1.SynchronizedConditionType, v1.ConditionFalse, v1alpha1.SynchronizedConditionReasonError, "")
return *result, err
}
Expand Down Expand Up @@ -191,6 +191,11 @@ func (r *ClusterReconciler) addOrRemoveFinalizer(cluster *v1alpha1.Cluster) *ctr

// If object is being deleted cleanup and remove the finalizer.
if !cluster.ObjectMeta.DeletionTimestamp.IsZero() {
if cluster.Status.ID == nil {
controllerutil.RemoveFinalizer(cluster, ClusterFinalizer)
return &ctrl.Result{}
}

// If object is already being deleted from Console API requeue.
if r.ConsoleClient.IsClusterDeleting(cluster.Status.ID) {
return &requeue
Expand Down

0 comments on commit 1647c3d

Please sign in to comment.