@@ -94,7 +94,7 @@ func setBootstrapReadyCondition(_ context.Context, machine *clusterv1.Machine, b
94
94
v1beta2conditions.FallbackCondition {
95
95
Status : v1beta2conditions .BoolToStatus (machine .Status .BootstrapReady ),
96
96
Reason : clusterv1 .MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason ,
97
- Message : fmt . Sprintf ( "%s status.ready is %t" , machine .Spec .Bootstrap .ConfigRef .Kind , machine .Status .BootstrapReady ),
97
+ Message : bootstrapConfigReadyFallBackMessage ( machine .Spec .Bootstrap .ConfigRef .Kind , machine .Status .BootstrapReady ),
98
98
},
99
99
); err != nil {
100
100
v1beta2conditions .Set (machine , metav1.Condition {
@@ -142,6 +142,10 @@ func setBootstrapReadyCondition(_ context.Context, machine *clusterv1.Machine, b
142
142
})
143
143
}
144
144
145
+ func bootstrapConfigReadyFallBackMessage (kind string , ready bool ) string {
146
+ return fmt .Sprintf ("%s status.ready is %t" , kind , ready )
147
+ }
148
+
145
149
func setInfrastructureReadyCondition (_ context.Context , machine * clusterv1.Machine , infraMachine * unstructured.Unstructured , infraMachineIsNotFound bool ) {
146
150
if infraMachine != nil {
147
151
if err := v1beta2conditions .SetMirrorConditionFromUnstructured (
@@ -150,7 +154,7 @@ func setInfrastructureReadyCondition(_ context.Context, machine *clusterv1.Machi
150
154
v1beta2conditions.FallbackCondition {
151
155
Status : v1beta2conditions .BoolToStatus (machine .Status .InfrastructureReady ),
152
156
Reason : clusterv1 .MachineInfrastructureReadyNoReasonReportedV1Beta2Reason ,
153
- Message : fmt . Sprintf ( "%s status.ready is %t" , machine .Spec .InfrastructureRef .Kind , machine .Status .InfrastructureReady ),
157
+ Message : infrastructureReadyFallBackMessage ( machine .Spec .InfrastructureRef .Kind , machine .Status .InfrastructureReady ),
154
158
},
155
159
); err != nil {
156
160
v1beta2conditions .Set (machine , metav1.Condition {
@@ -220,6 +224,10 @@ func setInfrastructureReadyCondition(_ context.Context, machine *clusterv1.Machi
220
224
})
221
225
}
222
226
227
+ func infrastructureReadyFallBackMessage (kind string , ready bool ) string {
228
+ return fmt .Sprintf ("%s status.ready is %t" , kind , ready )
229
+ }
230
+
223
231
func setNodeHealthyAndReadyConditions (ctx context.Context , machine * clusterv1.Machine , node * corev1.Node , nodeGetErr error , lastProbeSuccessTime time.Time , remoteConditionsGracePeriod time.Duration ) {
224
232
if time .Since (lastProbeSuccessTime ) > remoteConditionsGracePeriod {
225
233
var msg string
@@ -591,11 +599,27 @@ func setReadyCondition(ctx context.Context, machine *clusterv1.Machine) {
591
599
},
592
600
}
593
601
602
+ // Add overrides for conditions we don't to surface in the Ready condition with slightly different messages,
603
+ // mostly to improve when we will aggregate the Ready condition from many machines on MS, MD etc.
604
+ var overrideConditions v1beta2conditions.OverrideConditions
594
605
if ! machine .DeletionTimestamp .IsZero () {
595
- summaryOpts = append (summaryOpts , v1beta2conditions.OverrideConditions {calculateDeletingConditionForSummary (machine )})
606
+ overrideConditions = append (overrideConditions , calculateDeletingConditionForSummary (machine ))
607
+ }
608
+
609
+ if infrastructureReadyCondition := calculateInfrastructureReadyForSummary (machine ); infrastructureReadyCondition != nil {
610
+ overrideConditions = append (overrideConditions , * infrastructureReadyCondition )
611
+ }
612
+
613
+ if bootstrapReadyCondition := calculateBootstrapConfigReadyForSummary (machine ); bootstrapReadyCondition != nil {
614
+ overrideConditions = append (overrideConditions , * bootstrapReadyCondition )
615
+ }
616
+
617
+ if len (overrideConditions ) > 0 {
618
+ summaryOpts = append (summaryOpts , overrideConditions )
596
619
}
597
620
598
621
readyCondition , err := v1beta2conditions .NewSummaryCondition (machine , clusterv1 .MachineReadyV1Beta2Condition , summaryOpts ... )
622
+
599
623
if err != nil {
600
624
// Note, this could only happen if we hit edge cases in computing the summary, which should not happen due to the fact
601
625
// that we are passing a non empty list of ForConditionTypes.
@@ -654,6 +678,57 @@ func calculateDeletingConditionForSummary(machine *clusterv1.Machine) v1beta2con
654
678
}
655
679
}
656
680
681
+ func calculateInfrastructureReadyForSummary (machine * clusterv1.Machine ) * v1beta2conditions.ConditionWithOwnerInfo {
682
+ infrastructureReadyCondition := v1beta2conditions .Get (machine , clusterv1 .MachineInfrastructureReadyV1Beta2Condition )
683
+
684
+ if infrastructureReadyCondition == nil {
685
+ return nil
686
+ }
687
+
688
+ message := infrastructureReadyCondition .Message
689
+ if infrastructureReadyCondition .Status == metav1 .ConditionTrue && infrastructureReadyCondition .Message == infrastructureReadyFallBackMessage (machine .Spec .InfrastructureRef .Kind , machine .Status .InfrastructureReady ) {
690
+ message = ""
691
+ }
692
+
693
+ return & v1beta2conditions.ConditionWithOwnerInfo {
694
+ OwnerResource : v1beta2conditions.ConditionOwnerInfo {
695
+ Kind : "Machine" ,
696
+ Name : machine .Name ,
697
+ },
698
+ Condition : metav1.Condition {
699
+ Type : infrastructureReadyCondition .Type ,
700
+ Status : infrastructureReadyCondition .Status ,
701
+ Reason : infrastructureReadyCondition .Reason ,
702
+ Message : message ,
703
+ },
704
+ }
705
+ }
706
+
707
+ func calculateBootstrapConfigReadyForSummary (machine * clusterv1.Machine ) * v1beta2conditions.ConditionWithOwnerInfo {
708
+ bootstrapConfigReadyCondition := v1beta2conditions .Get (machine , clusterv1 .MachineBootstrapConfigReadyV1Beta2Condition )
709
+ if bootstrapConfigReadyCondition == nil {
710
+ return nil
711
+ }
712
+
713
+ message := bootstrapConfigReadyCondition .Message
714
+ if bootstrapConfigReadyCondition .Status == metav1 .ConditionTrue && machine .Spec .Bootstrap .ConfigRef != nil && bootstrapConfigReadyCondition .Message == bootstrapConfigReadyFallBackMessage (machine .Spec .Bootstrap .ConfigRef .Kind , machine .Status .BootstrapReady ) {
715
+ message = ""
716
+ }
717
+
718
+ return & v1beta2conditions.ConditionWithOwnerInfo {
719
+ OwnerResource : v1beta2conditions.ConditionOwnerInfo {
720
+ Kind : "Machine" ,
721
+ Name : machine .Name ,
722
+ },
723
+ Condition : metav1.Condition {
724
+ Type : bootstrapConfigReadyCondition .Type ,
725
+ Status : bootstrapConfigReadyCondition .Status ,
726
+ Reason : bootstrapConfigReadyCondition .Reason ,
727
+ Message : message ,
728
+ },
729
+ }
730
+ }
731
+
657
732
func setAvailableCondition (ctx context.Context , machine * clusterv1.Machine ) {
658
733
log := ctrl .LoggerFrom (ctx )
659
734
readyCondition := v1beta2conditions .Get (machine , clusterv1 .MachineReadyV1Beta2Condition )
0 commit comments