@@ -178,10 +178,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
178
178
Object : builder .MachineDeployment ("ns1" , "md0-abc123" ).
179
179
WithReplicas (2 ).
180
180
WithStatus (clusterv1.MachineDeploymentStatus {
181
- Replicas : int32 (1 ),
182
- UpdatedReplicas : int32 (1 ),
183
- ReadyReplicas : int32 (1 ),
184
- AvailableReplicas : int32 (1 ),
181
+ Replicas : int32 (1 ),
182
+ UpdatedReplicas : int32 (1 ),
183
+ ReadyReplicas : int32 (1 ),
184
+ AvailableReplicas : int32 (1 ),
185
+ UnavailableReplicas : int32 (0 ),
185
186
}).
186
187
Build (),
187
188
},
@@ -220,10 +221,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
220
221
Object : builder .MachineDeployment ("ns1" , "md0-abc123" ).
221
222
WithReplicas (2 ).
222
223
WithStatus (clusterv1.MachineDeploymentStatus {
223
- Replicas : int32 (2 ),
224
- UpdatedReplicas : int32 (2 ),
225
- ReadyReplicas : int32 (2 ),
226
- AvailableReplicas : int32 (2 ),
224
+ Replicas : int32 (2 ),
225
+ UpdatedReplicas : int32 (2 ),
226
+ ReadyReplicas : int32 (2 ),
227
+ AvailableReplicas : int32 (2 ),
228
+ UnavailableReplicas : int32 (0 ),
227
229
}).
228
230
Build (),
229
231
},
@@ -264,10 +266,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
264
266
Object : builder .MachineDeployment ("ns1" , "md0-abc123" ).
265
267
WithReplicas (2 ).
266
268
WithStatus (clusterv1.MachineDeploymentStatus {
267
- Replicas : int32 (2 ),
268
- UpdatedReplicas : int32 (2 ),
269
- ReadyReplicas : int32 (2 ),
270
- AvailableReplicas : int32 (2 ),
269
+ Replicas : int32 (2 ),
270
+ UpdatedReplicas : int32 (2 ),
271
+ ReadyReplicas : int32 (2 ),
272
+ AvailableReplicas : int32 (2 ),
273
+ UnavailableReplicas : int32 (0 ),
271
274
}).
272
275
Build (),
273
276
},
@@ -344,7 +347,7 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
344
347
wantConditionStatus : corev1 .ConditionTrue ,
345
348
},
346
349
{
347
- name : "should set the condition to false is some machine deployments have not picked the new version because other machine deployments are rolling out" ,
350
+ name : "should set the condition to false is some machine deployments have not picked the new version because other machine deployments are rolling out (not all replicas ready) " ,
348
351
reconcileErr : nil ,
349
352
cluster : & clusterv1.Cluster {},
350
353
s : & scope.Scope {
@@ -367,10 +370,12 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
367
370
WithReplicas (2 ).
368
371
WithVersion ("v1.22.0" ).
369
372
WithStatus (clusterv1.MachineDeploymentStatus {
370
- Replicas : int32 (1 ),
371
- UpdatedReplicas : int32 (1 ),
372
- ReadyReplicas : int32 (1 ),
373
- AvailableReplicas : int32 (1 ),
373
+ // MD is not ready because we don't have 2 updated, ready and available replicas.
374
+ Replicas : int32 (2 ),
375
+ UpdatedReplicas : int32 (1 ),
376
+ ReadyReplicas : int32 (1 ),
377
+ AvailableReplicas : int32 (1 ),
378
+ UnavailableReplicas : int32 (0 ),
374
379
}).
375
380
Build (),
376
381
},
@@ -379,10 +384,70 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
379
384
WithReplicas (2 ).
380
385
WithVersion ("v1.21.2" ).
381
386
WithStatus (clusterv1.MachineDeploymentStatus {
382
- Replicas : int32 (2 ),
383
- UpdatedReplicas : int32 (2 ),
384
- ReadyReplicas : int32 (2 ),
385
- AvailableReplicas : int32 (2 ),
387
+ Replicas : int32 (2 ),
388
+ UpdatedReplicas : int32 (2 ),
389
+ ReadyReplicas : int32 (2 ),
390
+ AvailableReplicas : int32 (2 ),
391
+ UnavailableReplicas : int32 (0 ),
392
+ }).
393
+ Build (),
394
+ },
395
+ },
396
+ },
397
+ UpgradeTracker : func () * scope.UpgradeTracker {
398
+ ut := scope .NewUpgradeTracker ()
399
+ ut .ControlPlane .PendingUpgrade = false
400
+ ut .MachineDeployments .MarkPendingUpgrade ("md1-abc123" )
401
+ return ut
402
+ }(),
403
+ HookResponseTracker : scope .NewHookResponseTracker (),
404
+ },
405
+ wantConditionStatus : corev1 .ConditionFalse ,
406
+ wantConditionReason : clusterv1 .TopologyReconciledMachineDeploymentsUpgradePendingReason ,
407
+ },
408
+ {
409
+ name : "should set the condition to false is some machine deployments have not picked the new version because other machine deployments are rolling out (unavailable replica)" ,
410
+ reconcileErr : nil ,
411
+ cluster : & clusterv1.Cluster {},
412
+ s : & scope.Scope {
413
+ Blueprint : & scope.ClusterBlueprint {
414
+ Topology : & clusterv1.Topology {
415
+ Version : "v1.22.0" ,
416
+ },
417
+ },
418
+ Current : & scope.ClusterState {
419
+ Cluster : & clusterv1.Cluster {},
420
+ ControlPlane : & scope.ControlPlaneState {
421
+ Object : builder .ControlPlane ("ns1" , "controlplane1" ).
422
+ WithVersion ("v1.22.0" ).
423
+ WithReplicas (3 ).
424
+ Build (),
425
+ },
426
+ MachineDeployments : scope.MachineDeploymentsStateMap {
427
+ "md0" : & scope.MachineDeploymentState {
428
+ Object : builder .MachineDeployment ("ns1" , "md0-abc123" ).
429
+ WithReplicas (2 ).
430
+ WithVersion ("v1.22.0" ).
431
+ WithStatus (clusterv1.MachineDeploymentStatus {
432
+ // MD is not ready because we still have an unavailable replica.
433
+ Replicas : int32 (2 ),
434
+ UpdatedReplicas : int32 (2 ),
435
+ ReadyReplicas : int32 (2 ),
436
+ AvailableReplicas : int32 (2 ),
437
+ UnavailableReplicas : int32 (1 ),
438
+ }).
439
+ Build (),
440
+ },
441
+ "md1" : & scope.MachineDeploymentState {
442
+ Object : builder .MachineDeployment ("ns1" , "md1-abc123" ).
443
+ WithReplicas (2 ).
444
+ WithVersion ("v1.21.2" ).
445
+ WithStatus (clusterv1.MachineDeploymentStatus {
446
+ Replicas : int32 (2 ),
447
+ UpdatedReplicas : int32 (2 ),
448
+ ReadyReplicas : int32 (2 ),
449
+ AvailableReplicas : int32 (2 ),
450
+ UnavailableReplicas : int32 (0 ),
386
451
}).
387
452
Build (),
388
453
},
@@ -423,10 +488,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
423
488
WithReplicas (2 ).
424
489
WithVersion ("v1.22.0" ).
425
490
WithStatus (clusterv1.MachineDeploymentStatus {
426
- Replicas : int32 (1 ),
427
- UpdatedReplicas : int32 (1 ),
428
- ReadyReplicas : int32 (1 ),
429
- AvailableReplicas : int32 (1 ),
491
+ Replicas : int32 (1 ),
492
+ UpdatedReplicas : int32 (1 ),
493
+ ReadyReplicas : int32 (1 ),
494
+ AvailableReplicas : int32 (1 ),
495
+ UnavailableReplicas : int32 (0 ),
430
496
}).
431
497
Build (),
432
498
},
@@ -435,10 +501,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
435
501
WithReplicas (2 ).
436
502
WithVersion ("v1.22.0" ).
437
503
WithStatus (clusterv1.MachineDeploymentStatus {
438
- Replicas : int32 (2 ),
439
- UpdatedReplicas : int32 (2 ),
440
- ReadyReplicas : int32 (2 ),
441
- AvailableReplicas : int32 (2 ),
504
+ Replicas : int32 (2 ),
505
+ UpdatedReplicas : int32 (2 ),
506
+ ReadyReplicas : int32 (2 ),
507
+ AvailableReplicas : int32 (2 ),
508
+ UnavailableReplicas : int32 (0 ),
442
509
}).
443
510
Build (),
444
511
},
0 commit comments