@@ -22,7 +22,6 @@ import (
22
22
23
23
. "github.com/onsi/gomega"
24
24
corev1 "k8s.io/api/core/v1"
25
- "k8s.io/apimachinery/pkg/api/meta"
26
25
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
26
"k8s.io/apimachinery/pkg/util/intstr"
28
27
"k8s.io/utils/ptr"
@@ -124,7 +123,7 @@ func Test_setAvailableCondition(t *testing.T) {
124
123
},
125
124
},
126
125
{
127
- name : "all the expected replicase are available" ,
126
+ name : "all the expected replicas are available" ,
128
127
machineDeployment : & clusterv1.MachineDeployment {
129
128
Spec : clusterv1.MachineDeploymentSpec {
130
129
Replicas : ptr .To (int32 (5 )),
@@ -146,7 +145,7 @@ func Test_setAvailableCondition(t *testing.T) {
146
145
},
147
146
},
148
147
{
149
- name : "some replicase are not available, but within MaxUnavailable range" ,
148
+ name : "some replicas are not available, but within MaxUnavailable range" ,
150
149
machineDeployment : & clusterv1.MachineDeployment {
151
150
Spec : clusterv1.MachineDeploymentSpec {
152
151
Replicas : ptr .To (int32 (5 )),
@@ -168,30 +167,7 @@ func Test_setAvailableCondition(t *testing.T) {
168
167
},
169
168
},
170
169
{
171
- name : "some replicase are not available, less than MaxUnavailable" ,
172
- machineDeployment : & clusterv1.MachineDeployment {
173
- Spec : clusterv1.MachineDeploymentSpec {
174
- Replicas : ptr .To (int32 (5 )),
175
- Strategy : & clusterv1.MachineDeploymentStrategy {
176
- Type : clusterv1 .RollingUpdateMachineDeploymentStrategyType ,
177
- RollingUpdate : & clusterv1.MachineRollingUpdateDeployment {
178
- MaxSurge : ptr .To (intstr .FromInt32 (1 )),
179
- MaxUnavailable : ptr .To (intstr .FromInt32 (1 )),
180
- },
181
- },
182
- },
183
- Status : clusterv1.MachineDeploymentStatus {V1Beta2 : & clusterv1.MachineDeploymentV1Beta2Status {AvailableReplicas : ptr .To (int32 (4 ))}},
184
- },
185
- getAndAdoptMachineSetsForDeploymentSucceeded : true ,
186
- expectCondition : metav1.Condition {
187
- Type : clusterv1 .MachineDeploymentAvailableV1Beta2Condition ,
188
- Status : metav1 .ConditionTrue ,
189
- Reason : clusterv1 .MachineDeploymentAvailableV1Beta2Reason ,
190
- Message : "" ,
191
- },
192
- },
193
- {
194
- name : "some replicase are not available, more than MaxUnavailable" ,
170
+ name : "some replicas are not available, more than MaxUnavailable" ,
195
171
machineDeployment : & clusterv1.MachineDeployment {
196
172
Spec : clusterv1.MachineDeploymentSpec {
197
173
Replicas : ptr .To (int32 (5 )),
@@ -210,7 +186,7 @@ func Test_setAvailableCondition(t *testing.T) {
210
186
Type : clusterv1 .MachineDeploymentAvailableV1Beta2Condition ,
211
187
Status : metav1 .ConditionFalse ,
212
188
Reason : clusterv1 .MachineDeploymentNotAvailableV1Beta2Reason ,
213
- Message : "3 available replicas, at least 4 required (spec.strategy.rollout.maxUnavailable is 1)" ,
189
+ Message : "3 available replicas, at least 4 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 5 )" ,
214
190
},
215
191
},
216
192
}
@@ -279,6 +255,22 @@ func Test_setScalingUpCondition(t *testing.T) {
279
255
Message : "Please check controller logs for errors" ,
280
256
},
281
257
},
258
+ {
259
+ name : "replicas not set" ,
260
+ machineDeployment : func () * clusterv1.MachineDeployment {
261
+ md := defaultMachineDeployment .DeepCopy ()
262
+ md .Spec .Replicas = nil
263
+ return md
264
+ }(),
265
+ bootstrapTemplateNotFound : false ,
266
+ infrastructureTemplateNotFound : false ,
267
+ getAndAdoptMachineSetsForDeploymentSucceeded : true ,
268
+ expectCondition : metav1.Condition {
269
+ Type : clusterv1 .MachineDeploymentScalingUpV1Beta2Condition ,
270
+ Status : metav1 .ConditionUnknown ,
271
+ Reason : clusterv1 .MachineDeploymentScalingUpWaitingForReplicasSetV1Beta2Reason ,
272
+ },
273
+ },
282
274
{
283
275
name : "not scaling up and no machines" ,
284
276
machineDeployment : defaultMachineDeployment ,
@@ -463,6 +455,20 @@ func Test_setScalingDownCondition(t *testing.T) {
463
455
Message : "Please check controller logs for errors" ,
464
456
},
465
457
},
458
+ {
459
+ name : "replicas not set" ,
460
+ machineDeployment : func () * clusterv1.MachineDeployment {
461
+ md := defaultMachineDeployment .DeepCopy ()
462
+ md .Spec .Replicas = nil
463
+ return md
464
+ }(),
465
+ getAndAdoptMachineSetsForDeploymentSucceeded : true ,
466
+ expectCondition : metav1.Condition {
467
+ Type : clusterv1 .MachineDeploymentScalingDownV1Beta2Condition ,
468
+ Status : metav1 .ConditionUnknown ,
469
+ Reason : clusterv1 .MachineDeploymentScalingDownWaitingForReplicasSetV1Beta2Reason ,
470
+ },
471
+ },
466
472
{
467
473
name : "not scaling down and no machines" ,
468
474
machineDeployment : defaultMachineDeployment ,
@@ -914,7 +920,7 @@ func Test_setRemediatingCondition(t *testing.T) {
914
920
},
915
921
},
916
922
{
917
- name : "With machines to be remediated by KCP " ,
923
+ name : "With machines to be remediated by MD/MS " ,
918
924
machineDeployment : & clusterv1.MachineDeployment {},
919
925
machines : []* clusterv1.Machine {
920
926
fakeMachine ("m1" , withConditions (healthCheckSucceeded )), // Healthy machine
@@ -930,7 +936,7 @@ func Test_setRemediatingCondition(t *testing.T) {
930
936
},
931
937
},
932
938
{
933
- name : "With one unhealthy machine not to be remediated by KCP " ,
939
+ name : "With one unhealthy machine not to be remediated by MD/MS " ,
934
940
machineDeployment : & clusterv1.MachineDeployment {},
935
941
machines : []* clusterv1.Machine {
936
942
fakeMachine ("m1" , withConditions (healthCheckSucceeded )), // Healthy machine
@@ -942,11 +948,11 @@ func Test_setRemediatingCondition(t *testing.T) {
942
948
Type : clusterv1 .MachineDeploymentRemediatingV1Beta2Condition ,
943
949
Status : metav1 .ConditionFalse ,
944
950
Reason : clusterv1 .MachineDeploymentNotRemediatingV1Beta2Reason ,
945
- Message : "Machine m2 is not healthy (not to be remediated by KCP )" ,
951
+ Message : "Machine m2 is not healthy (not to be remediated by MachineDeployment/MachineSet )" ,
946
952
},
947
953
},
948
954
{
949
- name : "With two unhealthy machine not to be remediated by KCP " ,
955
+ name : "With two unhealthy machine not to be remediated by MD/MS " ,
950
956
machineDeployment : & clusterv1.MachineDeployment {},
951
957
machines : []* clusterv1.Machine {
952
958
fakeMachine ("m1" , withConditions (healthCheckNotSucceeded )), // Unhealthy machine, not yet marked for remediation
@@ -958,7 +964,7 @@ func Test_setRemediatingCondition(t *testing.T) {
958
964
Type : clusterv1 .MachineDeploymentRemediatingV1Beta2Condition ,
959
965
Status : metav1 .ConditionFalse ,
960
966
Reason : clusterv1 .MachineDeploymentNotRemediatingV1Beta2Reason ,
961
- Message : "Machines m1, m2 are not healthy (not to be remediated by KCP )" ,
967
+ Message : "Machines m1, m2 are not healthy (not to be remediated by MachineDeployment/MachineSet )" ,
962
968
},
963
969
},
964
970
}
@@ -1047,7 +1053,7 @@ func Test_setDeletingCondition(t *testing.T) {
1047
1053
Type : clusterv1 .MachineDeploymentDeletingV1Beta2Condition ,
1048
1054
Status : metav1 .ConditionTrue ,
1049
1055
Reason : clusterv1 .MachineDeploymentDeletingDeletionTimestampSetV1Beta2Reason ,
1050
- Message : "Deleting 1 Machines " ,
1056
+ Message : "Deleting 1 Machine " ,
1051
1057
},
1052
1058
},
1053
1059
{
@@ -1065,7 +1071,7 @@ func Test_setDeletingCondition(t *testing.T) {
1065
1071
Type : clusterv1 .MachineDeploymentDeletingV1Beta2Condition ,
1066
1072
Status : metav1 .ConditionTrue ,
1067
1073
Reason : clusterv1 .MachineDeploymentDeletingDeletionTimestampSetV1Beta2Reason ,
1068
- Message : "Deleting 1 Machines and Machine m1 is in deletion since more than 30m" ,
1074
+ Message : "Deleting 1 Machine and Machine m1 is in deletion since more than 30m" ,
1069
1075
},
1070
1076
},
1071
1077
{
@@ -1174,7 +1180,7 @@ func withV1Beta2Condition(c metav1.Condition) fakeMachinesOption {
1174
1180
if m .Status .V1Beta2 == nil {
1175
1181
m .Status .V1Beta2 = & clusterv1.MachineV1Beta2Status {}
1176
1182
}
1177
- meta . SetStatusCondition ( & m . Status . V1Beta2 . Conditions , c )
1183
+ v1beta2conditions . Set ( m , c )
1178
1184
}
1179
1185
}
1180
1186
0 commit comments