@@ -352,8 +352,7 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
352
352
353
353
newCluster , err := rosaClient .CreateCluster (clusterSpec )
354
354
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 )
357
356
}
358
357
359
358
rosaScope .Info ("cluster created" , "state" , newCluster .Status ().State ())
@@ -377,15 +376,22 @@ func (r *ROSAControlPlaneReconciler) reconcileDelete(ctx context.Context, rosaSc
377
376
return ctrl.Result {}, err
378
377
}
379
378
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 {
381
386
if err := rosaClient .DeleteCluster (cluster .ID ()); err != nil {
382
387
return ctrl.Result {}, err
383
388
}
384
389
}
385
390
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
389
395
}
390
396
391
397
func (r * ROSAControlPlaneReconciler ) reconcileKubeconfig (ctx context.Context , rosaScope * scope.ROSAControlPlaneScope , rosaClient * rosa.RosaClient , cluster * cmv1.Cluster ) error {
0 commit comments