@@ -199,10 +199,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
199
199
Object : builder .MachineDeployment ("ns1" , "md0-abc123" ).
200
200
WithReplicas (2 ).
201
201
WithStatus (clusterv1.MachineDeploymentStatus {
202
- Replicas : int32 (1 ),
203
- UpdatedReplicas : int32 (1 ),
204
- ReadyReplicas : int32 (1 ),
205
- AvailableReplicas : int32 (1 ),
202
+ Replicas : int32 (1 ),
203
+ UpdatedReplicas : int32 (1 ),
204
+ ReadyReplicas : int32 (1 ),
205
+ AvailableReplicas : int32 (1 ),
206
+ UnavailableReplicas : int32 (0 ),
206
207
}).
207
208
Build (),
208
209
},
@@ -241,10 +242,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
241
242
Object : builder .MachineDeployment ("ns1" , "md0-abc123" ).
242
243
WithReplicas (2 ).
243
244
WithStatus (clusterv1.MachineDeploymentStatus {
244
- Replicas : int32 (2 ),
245
- UpdatedReplicas : int32 (2 ),
246
- ReadyReplicas : int32 (2 ),
247
- AvailableReplicas : int32 (2 ),
245
+ Replicas : int32 (2 ),
246
+ UpdatedReplicas : int32 (2 ),
247
+ ReadyReplicas : int32 (2 ),
248
+ AvailableReplicas : int32 (2 ),
249
+ UnavailableReplicas : int32 (0 ),
248
250
}).
249
251
Build (),
250
252
},
@@ -285,10 +287,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
285
287
Object : builder .MachineDeployment ("ns1" , "md0-abc123" ).
286
288
WithReplicas (2 ).
287
289
WithStatus (clusterv1.MachineDeploymentStatus {
288
- Replicas : int32 (2 ),
289
- UpdatedReplicas : int32 (2 ),
290
- ReadyReplicas : int32 (2 ),
291
- AvailableReplicas : int32 (2 ),
290
+ Replicas : int32 (2 ),
291
+ UpdatedReplicas : int32 (2 ),
292
+ ReadyReplicas : int32 (2 ),
293
+ AvailableReplicas : int32 (2 ),
294
+ UnavailableReplicas : int32 (0 ),
292
295
}).
293
296
Build (),
294
297
},
@@ -365,7 +368,7 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
365
368
wantConditionStatus : corev1 .ConditionTrue ,
366
369
},
367
370
{
368
- name : "should set the condition to false is some machine deployments have not picked the new version because other machine deployments are rolling out" ,
371
+ 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) " ,
369
372
reconcileErr : nil ,
370
373
cluster : & clusterv1.Cluster {},
371
374
s : & scope.Scope {
@@ -388,10 +391,12 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
388
391
WithReplicas (2 ).
389
392
WithVersion ("v1.22.0" ).
390
393
WithStatus (clusterv1.MachineDeploymentStatus {
391
- Replicas : int32 (1 ),
392
- UpdatedReplicas : int32 (1 ),
393
- ReadyReplicas : int32 (1 ),
394
- AvailableReplicas : int32 (1 ),
394
+ // MD is not ready because we don't have 2 updated, ready and available replicas.
395
+ Replicas : int32 (2 ),
396
+ UpdatedReplicas : int32 (1 ),
397
+ ReadyReplicas : int32 (1 ),
398
+ AvailableReplicas : int32 (1 ),
399
+ UnavailableReplicas : int32 (0 ),
395
400
}).
396
401
Build (),
397
402
},
@@ -400,10 +405,70 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
400
405
WithReplicas (2 ).
401
406
WithVersion ("v1.21.2" ).
402
407
WithStatus (clusterv1.MachineDeploymentStatus {
403
- Replicas : int32 (2 ),
404
- UpdatedReplicas : int32 (2 ),
405
- ReadyReplicas : int32 (2 ),
406
- AvailableReplicas : int32 (2 ),
408
+ Replicas : int32 (2 ),
409
+ UpdatedReplicas : int32 (2 ),
410
+ ReadyReplicas : int32 (2 ),
411
+ AvailableReplicas : int32 (2 ),
412
+ UnavailableReplicas : int32 (0 ),
413
+ }).
414
+ Build (),
415
+ },
416
+ },
417
+ },
418
+ UpgradeTracker : func () * scope.UpgradeTracker {
419
+ ut := scope .NewUpgradeTracker ()
420
+ ut .ControlPlane .PendingUpgrade = false
421
+ ut .MachineDeployments .MarkPendingUpgrade ("md1-abc123" )
422
+ return ut
423
+ }(),
424
+ HookResponseTracker : scope .NewHookResponseTracker (),
425
+ },
426
+ wantConditionStatus : corev1 .ConditionFalse ,
427
+ wantConditionReason : clusterv1 .TopologyReconciledMachineDeploymentsUpgradePendingReason ,
428
+ },
429
+ {
430
+ 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)" ,
431
+ reconcileErr : nil ,
432
+ cluster : & clusterv1.Cluster {},
433
+ s : & scope.Scope {
434
+ Blueprint : & scope.ClusterBlueprint {
435
+ Topology : & clusterv1.Topology {
436
+ Version : "v1.22.0" ,
437
+ },
438
+ },
439
+ Current : & scope.ClusterState {
440
+ Cluster : & clusterv1.Cluster {},
441
+ ControlPlane : & scope.ControlPlaneState {
442
+ Object : builder .ControlPlane ("ns1" , "controlplane1" ).
443
+ WithVersion ("v1.22.0" ).
444
+ WithReplicas (3 ).
445
+ Build (),
446
+ },
447
+ MachineDeployments : scope.MachineDeploymentsStateMap {
448
+ "md0" : & scope.MachineDeploymentState {
449
+ Object : builder .MachineDeployment ("ns1" , "md0-abc123" ).
450
+ WithReplicas (2 ).
451
+ WithVersion ("v1.22.0" ).
452
+ WithStatus (clusterv1.MachineDeploymentStatus {
453
+ // MD is not ready because we still have an unavailable replica.
454
+ Replicas : int32 (2 ),
455
+ UpdatedReplicas : int32 (2 ),
456
+ ReadyReplicas : int32 (2 ),
457
+ AvailableReplicas : int32 (2 ),
458
+ UnavailableReplicas : int32 (1 ),
459
+ }).
460
+ Build (),
461
+ },
462
+ "md1" : & scope.MachineDeploymentState {
463
+ Object : builder .MachineDeployment ("ns1" , "md1-abc123" ).
464
+ WithReplicas (2 ).
465
+ WithVersion ("v1.21.2" ).
466
+ WithStatus (clusterv1.MachineDeploymentStatus {
467
+ Replicas : int32 (2 ),
468
+ UpdatedReplicas : int32 (2 ),
469
+ ReadyReplicas : int32 (2 ),
470
+ AvailableReplicas : int32 (2 ),
471
+ UnavailableReplicas : int32 (0 ),
407
472
}).
408
473
Build (),
409
474
},
@@ -444,10 +509,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
444
509
WithReplicas (2 ).
445
510
WithVersion ("v1.22.0" ).
446
511
WithStatus (clusterv1.MachineDeploymentStatus {
447
- Replicas : int32 (1 ),
448
- UpdatedReplicas : int32 (1 ),
449
- ReadyReplicas : int32 (1 ),
450
- AvailableReplicas : int32 (1 ),
512
+ Replicas : int32 (1 ),
513
+ UpdatedReplicas : int32 (1 ),
514
+ ReadyReplicas : int32 (1 ),
515
+ AvailableReplicas : int32 (1 ),
516
+ UnavailableReplicas : int32 (0 ),
451
517
}).
452
518
Build (),
453
519
},
@@ -456,10 +522,11 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) {
456
522
WithReplicas (2 ).
457
523
WithVersion ("v1.22.0" ).
458
524
WithStatus (clusterv1.MachineDeploymentStatus {
459
- Replicas : int32 (2 ),
460
- UpdatedReplicas : int32 (2 ),
461
- ReadyReplicas : int32 (2 ),
462
- AvailableReplicas : int32 (2 ),
525
+ Replicas : int32 (2 ),
526
+ UpdatedReplicas : int32 (2 ),
527
+ ReadyReplicas : int32 (2 ),
528
+ AvailableReplicas : int32 (2 ),
529
+ UnavailableReplicas : int32 (0 ),
463
530
}).
464
531
Build (),
465
532
},
0 commit comments