@@ -67,6 +67,7 @@ func (r *Reconciler) updateStatus(ctx context.Context, s *scope) {
67
67
setWorkersAvailableCondition (ctx , s .cluster , expv1.MachinePoolList {}, s .descendants .machineDeployments , s .getDescendantsSucceeded )
68
68
setMachinesReadyCondition (ctx , s .cluster , allMachines , s .getDescendantsSucceeded )
69
69
setMachinesUpToDateCondition (ctx , s .cluster , allMachines , s .getDescendantsSucceeded )
70
+ setRollingOutCondition (ctx , s .cluster , s .controlPlane , expv1.MachinePoolList {}, s .descendants .machineDeployments , s .controlPlaneIsNotFound , s .getDescendantsSucceeded )
70
71
setScalingUpCondition (ctx , s .cluster , s .controlPlane , expv1.MachinePoolList {}, s .descendants .machineDeployments , s .descendants .machineSets , s .controlPlaneIsNotFound , s .getDescendantsSucceeded )
71
72
setScalingDownCondition (ctx , s .cluster , s .controlPlane , expv1.MachinePoolList {}, s .descendants .machineDeployments , s .descendants .machineSets , s .controlPlaneIsNotFound , s .getDescendantsSucceeded )
72
73
setRemediatingCondition (ctx , s .cluster , machinesToBeRemediated , unhealthyMachines , s .getDescendantsSucceeded )
@@ -760,6 +761,77 @@ func setRemediatingCondition(ctx context.Context, cluster *clusterv1.Cluster, ma
760
761
})
761
762
}
762
763
764
+ func setRollingOutCondition (ctx context.Context , cluster * clusterv1.Cluster , controlPlane * unstructured.Unstructured , machinePools expv1.MachinePoolList , machineDeployments clusterv1.MachineDeploymentList , controlPlaneIsNotFound bool , getDescendantsSucceeded bool ) {
765
+ log := ctrl .LoggerFrom (ctx )
766
+
767
+ // If there was some unexpected errors in getting control plane or listing descendants (this should never happen), surface it.
768
+ if (cluster .Spec .ControlPlaneRef != nil && controlPlane == nil && ! controlPlaneIsNotFound ) || ! getDescendantsSucceeded {
769
+ v1beta2conditions .Set (cluster , metav1.Condition {
770
+ Type : clusterv1 .ClusterRollingOutV1Beta2Condition ,
771
+ Status : metav1 .ConditionUnknown ,
772
+ Reason : clusterv1 .ClusterRollingOutInternalErrorV1Beta2Reason ,
773
+ Message : "Please check controller logs for errors" ,
774
+ })
775
+ return
776
+ }
777
+
778
+ if controlPlane == nil && len (machinePools .Items )+ len (machineDeployments .Items ) == 0 {
779
+ v1beta2conditions .Set (cluster , metav1.Condition {
780
+ Type : clusterv1 .ClusterRollingOutV1Beta2Condition ,
781
+ Status : metav1 .ConditionFalse ,
782
+ Reason : clusterv1 .ClusterNotRollingOutV1Beta2Reason ,
783
+ })
784
+ return
785
+ }
786
+
787
+ ws := make ([]aggregationWrapper , 0 , len (machinePools .Items )+ len (machineDeployments .Items )+ 1 )
788
+ if controlPlane != nil {
789
+ // control plane is considered only if it is reporting the condition (the contract does not require conditions to be reported)
790
+ // Note: this implies that it won't surface as "Conditions RollingOut not yet reported from ...".
791
+ if c , err := v1beta2conditions .UnstructuredGet (controlPlane , clusterv1 .RollingOutV1Beta2Condition ); err == nil && c != nil {
792
+ ws = append (ws , aggregationWrapper {cp : controlPlane })
793
+ }
794
+ }
795
+ for _ , mp := range machinePools .Items {
796
+ ws = append (ws , aggregationWrapper {mp : & mp })
797
+ }
798
+ for _ , md := range machineDeployments .Items {
799
+ ws = append (ws , aggregationWrapper {md : & md })
800
+ }
801
+
802
+ rollingOutCondition , err := v1beta2conditions .NewAggregateCondition (
803
+ ws , clusterv1 .RollingOutV1Beta2Condition ,
804
+ v1beta2conditions .TargetConditionType (clusterv1 .ClusterRollingOutV1Beta2Condition ),
805
+ // Instruct aggregate to consider RollingOut condition with negative polarity.
806
+ v1beta2conditions.NegativePolarityConditionTypes {clusterv1 .RollingOutV1Beta2Condition },
807
+ // Using a custom merge strategy to override reasons applied during merge and to ensure merge
808
+ // takes into account the fact the RollingOut has negative polarity.
809
+ v1beta2conditions.CustomMergeStrategy {
810
+ MergeStrategy : v1beta2conditions .DefaultMergeStrategy (
811
+ v1beta2conditions .TargetConditionHasPositivePolarity (false ),
812
+ v1beta2conditions .ComputeReasonFunc (v1beta2conditions .GetDefaultComputeMergeReasonFunc (
813
+ clusterv1 .ClusterRollingOutV1Beta2Reason ,
814
+ clusterv1 .ClusterRollingOutUnknownV1Beta2Reason ,
815
+ clusterv1 .ClusterNotRollingOutV1Beta2Reason ,
816
+ )),
817
+ v1beta2conditions .GetPriorityFunc (v1beta2conditions .GetDefaultMergePriorityFunc (clusterv1 .RollingOutV1Beta2Condition )),
818
+ ),
819
+ },
820
+ )
821
+ if err != nil {
822
+ log .Error (err , "Failed to aggregate ControlPlane, MachinePool, MachineDeployment, MachineSet's RollingOut conditions" )
823
+ v1beta2conditions .Set (cluster , metav1.Condition {
824
+ Type : clusterv1 .ClusterRollingOutV1Beta2Condition ,
825
+ Status : metav1 .ConditionUnknown ,
826
+ Reason : clusterv1 .ClusterRollingOutInternalErrorV1Beta2Reason ,
827
+ Message : "Please check controller logs for errors" ,
828
+ })
829
+ return
830
+ }
831
+
832
+ v1beta2conditions .Set (cluster , * rollingOutCondition )
833
+ }
834
+
763
835
func setScalingUpCondition (ctx context.Context , cluster * clusterv1.Cluster , controlPlane * unstructured.Unstructured , machinePools expv1.MachinePoolList , machineDeployments clusterv1.MachineDeploymentList , machineSets clusterv1.MachineSetList , controlPlaneIsNotFound bool , getDescendantsSucceeded bool ) {
764
836
log := ctrl .LoggerFrom (ctx )
765
837
0 commit comments