@@ -339,7 +339,7 @@ func Test_setRollingOutCondition(t *testing.T) {
339
339
}
340
340
341
341
func Test_setScalingUpCondition (t * testing.T ) {
342
- defaultMachineDeployment := & clusterv1.MachineDeployment {
342
+ machineDeploymentWith0Replicas := & clusterv1.MachineDeployment {
343
343
Spec : clusterv1.MachineDeploymentSpec {
344
344
Replicas : ptr.To [int32 ](0 ),
345
345
Template : clusterv1.MachineTemplateSpec {
@@ -361,10 +361,10 @@ func Test_setScalingUpCondition(t *testing.T) {
361
361
},
362
362
}
363
363
364
- scalingUpMachineDeploymentWith3Replicas := defaultMachineDeployment .DeepCopy ()
365
- scalingUpMachineDeploymentWith3Replicas .Spec .Replicas = ptr.To [int32 ](3 )
364
+ machineDeploymentWith3Replicas := machineDeploymentWith0Replicas .DeepCopy ()
365
+ machineDeploymentWith3Replicas .Spec .Replicas = ptr.To [int32 ](3 )
366
366
367
- deletingMachineDeploymentWith3Replicas := defaultMachineDeployment .DeepCopy ()
367
+ deletingMachineDeploymentWith3Replicas := machineDeploymentWith0Replicas .DeepCopy ()
368
368
deletingMachineDeploymentWith3Replicas .DeletionTimestamp = ptr .To (metav1 .Now ())
369
369
deletingMachineDeploymentWith3Replicas .Spec .Replicas = ptr.To [int32 ](3 )
370
370
@@ -380,7 +380,7 @@ func Test_setScalingUpCondition(t *testing.T) {
380
380
}{
381
381
{
382
382
name : "getAndAdoptMachineSetsForDeploymentSucceeded failed" ,
383
- machineDeployment : defaultMachineDeployment ,
383
+ machineDeployment : machineDeploymentWith0Replicas . DeepCopy () ,
384
384
bootstrapTemplateNotFound : false ,
385
385
infrastructureTemplateNotFound : false ,
386
386
getAndAdoptMachineSetsForDeploymentSucceeded : false ,
@@ -395,7 +395,7 @@ func Test_setScalingUpCondition(t *testing.T) {
395
395
{
396
396
name : "replicas not set" ,
397
397
machineDeployment : func () * clusterv1.MachineDeployment {
398
- md := defaultMachineDeployment .DeepCopy ()
398
+ md := machineDeploymentWith0Replicas .DeepCopy ()
399
399
md .Spec .Replicas = nil
400
400
return md
401
401
}(),
@@ -412,7 +412,7 @@ func Test_setScalingUpCondition(t *testing.T) {
412
412
},
413
413
{
414
414
name : "not scaling up and no machines" ,
415
- machineDeployment : defaultMachineDeployment ,
415
+ machineDeployment : machineDeploymentWith0Replicas . DeepCopy () ,
416
416
bootstrapTemplateNotFound : false ,
417
417
infrastructureTemplateNotFound : false ,
418
418
getAndAdoptMachineSetsForDeploymentSucceeded : true ,
@@ -425,7 +425,7 @@ func Test_setScalingUpCondition(t *testing.T) {
425
425
},
426
426
{
427
427
name : "not scaling up with machines" ,
428
- machineDeployment : scalingUpMachineDeploymentWith3Replicas ,
428
+ machineDeployment : machineDeploymentWith3Replicas . DeepCopy () ,
429
429
machineSets : []* clusterv1.MachineSet {
430
430
fakeMachineSet ("ms1" , withStatusReplicas (1 )),
431
431
fakeMachineSet ("ms2" , withStatusReplicas (2 )),
@@ -442,7 +442,7 @@ func Test_setScalingUpCondition(t *testing.T) {
442
442
},
443
443
{
444
444
name : "not scaling up and no machines and bootstrapConfig object not found" ,
445
- machineDeployment : defaultMachineDeployment ,
445
+ machineDeployment : machineDeploymentWith0Replicas . DeepCopy () ,
446
446
bootstrapTemplateNotFound : true ,
447
447
infrastructureTemplateNotFound : false ,
448
448
getAndAdoptMachineSetsForDeploymentSucceeded : true ,
@@ -456,7 +456,7 @@ func Test_setScalingUpCondition(t *testing.T) {
456
456
},
457
457
{
458
458
name : "not scaling up and no machines and infrastructure object not found" ,
459
- machineDeployment : defaultMachineDeployment ,
459
+ machineDeployment : machineDeploymentWith0Replicas . DeepCopy () ,
460
460
bootstrapTemplateNotFound : false ,
461
461
infrastructureTemplateNotFound : true ,
462
462
getAndAdoptMachineSetsForDeploymentSucceeded : true ,
@@ -470,7 +470,7 @@ func Test_setScalingUpCondition(t *testing.T) {
470
470
},
471
471
{
472
472
name : "not scaling up and no machines and bootstrapConfig and infrastructure object not found" ,
473
- machineDeployment : defaultMachineDeployment ,
473
+ machineDeployment : machineDeploymentWith0Replicas . DeepCopy () ,
474
474
bootstrapTemplateNotFound : true ,
475
475
infrastructureTemplateNotFound : true ,
476
476
getAndAdoptMachineSetsForDeploymentSucceeded : true ,
@@ -484,7 +484,7 @@ func Test_setScalingUpCondition(t *testing.T) {
484
484
},
485
485
{
486
486
name : "scaling up" ,
487
- machineDeployment : scalingUpMachineDeploymentWith3Replicas ,
487
+ machineDeployment : machineDeploymentWith3Replicas . DeepCopy () ,
488
488
bootstrapTemplateNotFound : false ,
489
489
infrastructureTemplateNotFound : false ,
490
490
getAndAdoptMachineSetsForDeploymentSucceeded : true ,
@@ -498,7 +498,7 @@ func Test_setScalingUpCondition(t *testing.T) {
498
498
},
499
499
{
500
500
name : "scaling up with machines" ,
501
- machineDeployment : scalingUpMachineDeploymentWith3Replicas ,
501
+ machineDeployment : machineDeploymentWith3Replicas . DeepCopy () ,
502
502
machineSets : []* clusterv1.MachineSet {
503
503
fakeMachineSet ("ms1" , withStatusReplicas (1 )),
504
504
fakeMachineSet ("ms2" , withStatusReplicas (1 )),
@@ -516,7 +516,7 @@ func Test_setScalingUpCondition(t *testing.T) {
516
516
},
517
517
{
518
518
name : "scaling up and blocked by bootstrap object" ,
519
- machineDeployment : scalingUpMachineDeploymentWith3Replicas ,
519
+ machineDeployment : machineDeploymentWith3Replicas . DeepCopy () ,
520
520
bootstrapTemplateNotFound : true ,
521
521
infrastructureTemplateNotFound : false ,
522
522
getAndAdoptMachineSetsForDeploymentSucceeded : true ,
@@ -530,7 +530,7 @@ func Test_setScalingUpCondition(t *testing.T) {
530
530
},
531
531
{
532
532
name : "scaling up and blocked by infrastructure object" ,
533
- machineDeployment : scalingUpMachineDeploymentWith3Replicas ,
533
+ machineDeployment : machineDeploymentWith3Replicas . DeepCopy () ,
534
534
bootstrapTemplateNotFound : false ,
535
535
infrastructureTemplateNotFound : true ,
536
536
getAndAdoptMachineSetsForDeploymentSucceeded : true ,
@@ -544,7 +544,7 @@ func Test_setScalingUpCondition(t *testing.T) {
544
544
},
545
545
{
546
546
name : "deleting, don't show block message when templates are not found" ,
547
- machineDeployment : deletingMachineDeploymentWith3Replicas ,
547
+ machineDeployment : deletingMachineDeploymentWith3Replicas . DeepCopy () ,
548
548
machineSets : []* clusterv1.MachineSet {{}, {}, {}},
549
549
bootstrapTemplateNotFound : true ,
550
550
infrastructureTemplateNotFound : true ,
@@ -554,7 +554,7 @@ func Test_setScalingUpCondition(t *testing.T) {
554
554
Status : metav1 .ConditionFalse ,
555
555
Reason : clusterv1 .MachineDeploymentNotScalingUpReason ,
556
556
},
557
- expectedPhase : clusterv1 .MachineDeploymentPhaseRunning ,
557
+ expectedPhase : clusterv1 .MachineDeploymentPhaseScalingDown ,
558
558
},
559
559
}
560
560
for _ , tt := range tests {
@@ -762,7 +762,7 @@ After above Pods have been removed from the Node, the following Pods will be evi
762
762
Status : metav1 .ConditionFalse ,
763
763
Reason : clusterv1 .MachineDeploymentNotScalingDownReason ,
764
764
},
765
- expectedPhase : clusterv1 .MachineDeploymentPhaseRunning ,
765
+ expectedPhase : clusterv1 .MachineDeploymentPhaseScalingDown ,
766
766
},
767
767
{
768
768
name : "deleting machine deployment having 1 replica" ,
0 commit comments