@@ -614,6 +614,12 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context,
614614
615615 controllerutil .RemoveFinalizer (rcp , controlplanev1 .RKE2ControlPlaneFinalizer )
616616
617+ conditions .Set (rcp , metav1.Condition {
618+ Type : controlplanev1 .RKE2ControlPlaneDeletingCondition ,
619+ Status : metav1 .ConditionTrue ,
620+ Reason : controlplanev1 .RKE2ControlPlaneDeletingDeletionCompletedReason ,
621+ })
622+
617623 return ctrl.Result {}, nil
618624 }
619625
@@ -649,6 +655,13 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context,
649655 clusterv1 .ConditionSeverityInfo ,
650656 "Waiting for worker nodes to be deleted first" )
651657
658+ conditions .Set (rcp , metav1.Condition {
659+ Type : controlplanev1 .RKE2ControlPlaneDeletingCondition ,
660+ Status : metav1 .ConditionTrue ,
661+ Reason : controlplanev1 .RKE2ControlPlaneDeletingWaitingForWorkersDeletionReason ,
662+ Message : "Waiting for worker nodes to be deleted first" ,
663+ })
664+
652665 return ctrl.Result {RequeueAfter : deleteRequeueAfter }, nil
653666 }
654667
@@ -702,6 +715,13 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context,
702715
703716 v1beta1conditions .MarkFalse (rcp , controlplanev1 .ResizedV1Beta1Condition , clusterv1 .DeletingV1Beta1Reason , clusterv1 .ConditionSeverityInfo , "" )
704717
718+ conditions .Set (rcp , metav1.Condition {
719+ Type : controlplanev1 .RKE2ControlPlaneDeletingCondition ,
720+ Status : metav1 .ConditionTrue ,
721+ Reason : controlplanev1 .RKE2ControlPlaneDeletingWaitingForMachineDeletionReason ,
722+ Message : "Waiting for control plane Machines to be deleted" ,
723+ })
724+
705725 return ctrl.Result {RequeueAfter : deleteRequeueAfter }, nil
706726}
707727
@@ -775,6 +795,11 @@ func (r *RKE2ControlPlaneReconciler) reconcileControlPlaneConditions(
775795) (res ctrl.Result , retErr error ) {
776796 logger := log .FromContext (ctx )
777797
798+ // If the control plane is being deleted, we don't need to reconcile conditions. The DeletingCondition is set directly in reconcileDelete.
799+ if ! controlPlane .RCP .DeletionTimestamp .IsZero () {
800+ return ctrl.Result {}, nil
801+ }
802+
778803 // If the cluster is not yet initialized, there is no way to connect to the workload cluster and fetch information
779804 // for updating conditions. Return early.
780805 // We additionally check for the ControlPlaneInitialized condition. The ControlPlaneInitialized condition is set at the same time
@@ -799,7 +824,6 @@ func (r *RKE2ControlPlaneReconciler) reconcileControlPlaneConditions(
799824 readyCPMachines := controlPlane .Machines .Filter (collections .IsReady ())
800825
801826 if readyCPMachines .Len () == 0 {
802- controlPlane .RCP .Status .Initialization .ControlPlaneInitialized = ptr .To (false )
803827 controlPlane .RCP .Status .ReadyReplicas = ptr .To (int32 (0 ))
804828 controlPlane .RCP .Status .AvailableServerIPs = nil
805829
0 commit comments