@@ -609,6 +609,12 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context,
609609
610610 controllerutil .RemoveFinalizer (rcp , controlplanev1 .RKE2ControlPlaneFinalizer )
611611
612+ conditions .Set (rcp , metav1.Condition {
613+ Type : controlplanev1 .RKE2ControlPlaneDeletingCondition ,
614+ Status : metav1 .ConditionTrue ,
615+ Reason : controlplanev1 .RKE2ControlPlaneDeletingDeletionCompletedReason ,
616+ })
617+
612618 return ctrl.Result {}, nil
613619 }
614620
@@ -644,6 +650,13 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context,
644650 clusterv1 .ConditionSeverityInfo ,
645651 "Waiting for worker nodes to be deleted first" )
646652
653+ conditions .Set (rcp , metav1.Condition {
654+ Type : controlplanev1 .RKE2ControlPlaneDeletingCondition ,
655+ Status : metav1 .ConditionTrue ,
656+ Reason : controlplanev1 .RKE2ControlPlaneDeletingWaitingForWorkersDeletionReason ,
657+ Message : "Waiting for worker nodes to be deleted first" ,
658+ })
659+
647660 return ctrl.Result {RequeueAfter : deleteRequeueAfter }, nil
648661 }
649662
@@ -697,6 +710,13 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context,
697710
698711 v1beta1conditions .MarkFalse (rcp , controlplanev1 .ResizedV1Beta1Condition , clusterv1 .DeletingV1Beta1Reason , clusterv1 .ConditionSeverityInfo , "" )
699712
713+ conditions .Set (rcp , metav1.Condition {
714+ Type : controlplanev1 .RKE2ControlPlaneDeletingCondition ,
715+ Status : metav1 .ConditionTrue ,
716+ Reason : controlplanev1 .RKE2ControlPlaneDeletingWaitingForMachineDeletionReason ,
717+ Message : "Waiting for control plane Machines to be deleted" ,
718+ })
719+
700720 return ctrl.Result {RequeueAfter : deleteRequeueAfter }, nil
701721}
702722
@@ -770,6 +790,11 @@ func (r *RKE2ControlPlaneReconciler) reconcileControlPlaneConditions(
770790) (res ctrl.Result , retErr error ) {
771791 logger := log .FromContext (ctx )
772792
793+ // If the control plane is being deleted, we don't need to reconcile conditions. The DeletingCondition is set directly in reconcileDelete.
794+ if ! controlPlane .RCP .DeletionTimestamp .IsZero () {
795+ return ctrl.Result {}, nil
796+ }
797+
773798 // If the cluster is not yet initialized, there is no way to connect to the workload cluster and fetch information
774799 // for updating conditions. Return early.
775800 // We additionally check for the ControlPlaneInitialized condition. The ControlPlaneInitialized condition is set at the same time
@@ -794,7 +819,6 @@ func (r *RKE2ControlPlaneReconciler) reconcileControlPlaneConditions(
794819 readyCPMachines := controlPlane .Machines .Filter (collections .IsReady ())
795820
796821 if readyCPMachines .Len () == 0 {
797- controlPlane .RCP .Status .Initialization .ControlPlaneInitialized = ptr .To (false )
798822 controlPlane .RCP .Status .ReadyReplicas = ptr .To (int32 (0 ))
799823 controlPlane .RCP .Status .AvailableServerIPs = nil
800824
0 commit comments