@@ -194,6 +194,7 @@ func Test_setScalingUpCondition(t *testing.T) {
194
194
bootstrapObjectNotFound bool
195
195
infrastructureObjectNotFound bool
196
196
getAndAdoptMachinesForMachineSetSucceeded bool
197
+ scaleUpPreflightCheckErrMessage string
197
198
expectCondition metav1.Condition
198
199
}{
199
200
{
@@ -299,6 +300,27 @@ func Test_setScalingUpCondition(t *testing.T) {
299
300
Message : "Scaling up from 0 to 3 replicas is blocked because DockerMachineTemplate does not exist" ,
300
301
},
301
302
},
303
+ {
304
+ name : "scaling up and blocked by bootstrap and infrastructure object and preflight checks" ,
305
+ ms : scalingUpMachineSetWith3Replicas ,
306
+ bootstrapObjectNotFound : true ,
307
+ infrastructureObjectNotFound : true ,
308
+ getAndAdoptMachinesForMachineSetSucceeded : true ,
309
+ // This preflight check error can happen when a MachineSet is scaling up while the control plane
310
+ // already has a newer Kubernetes version.
311
+ scaleUpPreflightCheckErrMessage : "MachineSet version (1.25.5) and ControlPlane version (1.26.2) " +
312
+ "do not conform to kubeadm version skew policy as kubeadm only supports joining with the same " +
313
+ "major+minor version as the control plane (\" KubeadmVersionSkew\" preflight check failed)" ,
314
+ expectCondition : metav1.Condition {
315
+ Type : clusterv1 .MachineSetScalingUpV1Beta2Condition ,
316
+ Status : metav1 .ConditionTrue ,
317
+ Reason : clusterv1 .MachineSetScalingUpV1Beta2Reason ,
318
+ Message : "Scaling up from 0 to 3 replicas is blocked because KubeadmBootstrapTemplate and DockerMachineTemplate " +
319
+ "do not exist and MachineSet version (1.25.5) and ControlPlane version (1.26.2) " +
320
+ "do not conform to kubeadm version skew policy as kubeadm only supports joining with the same " +
321
+ "major+minor version as the control plane (\" KubeadmVersionSkew\" preflight check failed)" ,
322
+ },
323
+ },
302
324
{
303
325
name : "deleting" ,
304
326
ms : deletingMachineSetWith3Replicas ,
@@ -317,7 +339,7 @@ func Test_setScalingUpCondition(t *testing.T) {
317
339
t .Run (tt .name , func (t * testing.T ) {
318
340
g := NewWithT (t )
319
341
320
- setScalingUpCondition (ctx , tt .ms , tt .machines , tt .bootstrapObjectNotFound , tt .infrastructureObjectNotFound , tt .getAndAdoptMachinesForMachineSetSucceeded )
342
+ setScalingUpCondition (ctx , tt .ms , tt .machines , tt .bootstrapObjectNotFound , tt .infrastructureObjectNotFound , tt .getAndAdoptMachinesForMachineSetSucceeded , tt . scaleUpPreflightCheckErrMessage )
321
343
322
344
condition := v1beta2conditions .Get (tt .ms , clusterv1 .MachineSetScalingUpV1Beta2Condition )
323
345
g .Expect (condition ).ToNot (BeNil ())
@@ -758,13 +780,15 @@ func Test_setRemediatingCondition(t *testing.T) {
758
780
healthCheckSucceeded := clusterv1.Condition {Type : clusterv1 .MachineHealthCheckSucceededV1Beta2Condition , Status : corev1 .ConditionTrue }
759
781
healthCheckNotSucceeded := clusterv1.Condition {Type : clusterv1 .MachineHealthCheckSucceededV1Beta2Condition , Status : corev1 .ConditionFalse }
760
782
ownerRemediated := clusterv1.Condition {Type : clusterv1 .MachineOwnerRemediatedCondition , Status : corev1 .ConditionFalse }
761
- ownerRemediatedV1Beta2 := metav1.Condition {Type : clusterv1 .MachineOwnerRemediatedV1Beta2Condition , Status : metav1 .ConditionFalse , Message : "Remediation in progress" }
783
+ ownerRemediatedV1Beta2 := metav1.Condition {Type : clusterv1 .MachineOwnerRemediatedV1Beta2Condition , Status : metav1 .ConditionFalse , Reason : clusterv1 .MachineSetMachineRemediationMachineDeletedV1Beta2Reason , Message : "Machine deletionTimestamp set" }
784
+ ownerRemediatedWaitingForRemediationV1Beta2 := metav1.Condition {Type : clusterv1 .MachineOwnerRemediatedV1Beta2Condition , Status : metav1 .ConditionFalse , Reason : clusterv1 .MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason , Message : "Waiting for remediation" }
762
785
763
786
tests := []struct {
764
787
name string
765
788
machineSet * clusterv1.MachineSet
766
789
machines []* clusterv1.Machine
767
790
getAndAdoptMachinesForMachineSetSucceeded bool
791
+ remediationPreflightCheckErrMessage string
768
792
expectCondition metav1.Condition
769
793
}{
770
794
{
@@ -806,7 +830,27 @@ func Test_setRemediatingCondition(t *testing.T) {
806
830
Type : clusterv1 .MachineSetRemediatingV1Beta2Condition ,
807
831
Status : metav1 .ConditionTrue ,
808
832
Reason : clusterv1 .MachineSetRemediatingV1Beta2Reason ,
809
- Message : "Remediation in progress from Machine m3" ,
833
+ Message : "Machine deletionTimestamp set from Machine m3" ,
834
+ },
835
+ },
836
+ {
837
+ name : "With machines to be remediated by MS and preflight check error" ,
838
+ machineSet : & clusterv1.MachineSet {},
839
+ machines : []* clusterv1.Machine {
840
+ fakeMachine ("m1" , withConditions (healthCheckSucceeded )), // Healthy machine
841
+ fakeMachine ("m2" , withConditions (healthCheckNotSucceeded )), // Unhealthy machine, not yet marked for remediation
842
+ fakeMachine ("m3" , withConditions (healthCheckNotSucceeded , ownerRemediated ), withV1Beta2Condition (ownerRemediatedV1Beta2 )),
843
+ fakeMachine ("m4" , withConditions (healthCheckNotSucceeded , ownerRemediated ), withV1Beta2Condition (ownerRemediatedWaitingForRemediationV1Beta2 )),
844
+ },
845
+ getAndAdoptMachinesForMachineSetSucceeded : true ,
846
+ // This preflight check error can happen when a Machine becomes unhealthy while the control plane is upgrading.
847
+ remediationPreflightCheckErrMessage : "KubeadmControlPlane ns1/cp1 is upgrading (\" ControlPlaneIsStable\" preflight check failed)" ,
848
+ expectCondition : metav1.Condition {
849
+ Type : clusterv1 .MachineSetRemediatingV1Beta2Condition ,
850
+ Status : metav1 .ConditionTrue ,
851
+ Reason : clusterv1 .MachineSetRemediatingV1Beta2Reason ,
852
+ Message : "Triggering further remediations is blocked because KubeadmControlPlane ns1/cp1 is upgrading (\" ControlPlaneIsStable\" preflight check failed); " +
853
+ "Machine deletionTimestamp set from Machine m3; Waiting for remediation from Machine m4" ,
810
854
},
811
855
},
812
856
{
@@ -852,7 +896,7 @@ func Test_setRemediatingCondition(t *testing.T) {
852
896
machinesToBeRemediated = machines .Filter (collections .IsUnhealthyAndOwnerRemediated )
853
897
unHealthyMachines = machines .Filter (collections .IsUnhealthy )
854
898
}
855
- setRemediatingCondition (ctx , tt .machineSet , machinesToBeRemediated , unHealthyMachines , tt .getAndAdoptMachinesForMachineSetSucceeded )
899
+ setRemediatingCondition (ctx , tt .machineSet , machinesToBeRemediated , unHealthyMachines , tt .getAndAdoptMachinesForMachineSetSucceeded , tt . remediationPreflightCheckErrMessage )
856
900
857
901
condition := v1beta2conditions .Get (tt .machineSet , clusterv1 .MachineSetRemediatingV1Beta2Condition )
858
902
g .Expect (condition ).ToNot (BeNil ())
0 commit comments