@@ -352,8 +352,7 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
352352
353353 newCluster , err := rosaClient .CreateCluster (clusterSpec )
354354 if err != nil {
355- rosaScope .Info ("error" , "error" , err )
356- return ctrl.Result {RequeueAfter : 10 * time .Second }, nil
355+ return ctrl.Result {}, fmt .Errorf ("failed to create ROSA cluster: %w" , err )
357356 }
358357
359358 rosaScope .Info ("cluster created" , "state" , newCluster .Status ().State ())
@@ -377,15 +376,22 @@ func (r *ROSAControlPlaneReconciler) reconcileDelete(ctx context.Context, rosaSc
377376 return ctrl.Result {}, err
378377 }
379378
380- if cluster != nil {
379+ if cluster == nil {
380+ // cluster is fully deleted, remove finalizer.
381+ controllerutil .RemoveFinalizer (rosaScope .ControlPlane , ROSAControlPlaneFinalizer )
382+ return ctrl.Result {}, nil
383+ }
384+
385+ if cluster .Status ().State () != cmv1 .ClusterStateUninstalling {
381386 if err := rosaClient .DeleteCluster (cluster .ID ()); err != nil {
382387 return ctrl.Result {}, err
383388 }
384389 }
385390
386- controllerutil .RemoveFinalizer (rosaScope .ControlPlane , ROSAControlPlaneFinalizer )
387-
388- return ctrl.Result {}, nil
391+ rosaScope .ControlPlane .Status .Ready = false
392+ rosaScope .Info ("waiting for cluster to be deleted" )
393+ // Requeue to remove the finalizer when the cluster is fully deleted.
394+ return ctrl.Result {RequeueAfter : time .Second * 60 }, nil
389395}
390396
391397func (r * ROSAControlPlaneReconciler ) reconcileKubeconfig (ctx context.Context , rosaScope * scope.ROSAControlPlaneScope , rosaClient * rosa.RosaClient , cluster * cmv1.Cluster ) error {
0 commit comments