@@ -477,18 +477,17 @@ func (r *Reconciler) scale(ctx context.Context, deployment *clusterv1.MachineDep
477
477
478
478
// syncDeploymentStatus checks if the status is up-to-date and sync it if necessary.
479
479
func (r * Reconciler ) syncDeploymentStatus (allMSs []* clusterv1.MachineSet , newMS * clusterv1.MachineSet , md * clusterv1.MachineDeployment ) error {
480
- md .Status = calculateStatus (allMSs , newMS , md )
480
+ md .Status = calculateV1Beta1Status (allMSs , newMS , md )
481
481
482
482
// minReplicasNeeded will be equal to md.Spec.Replicas when the strategy is not RollingUpdateMachineDeploymentStrategyType.
483
483
minReplicasNeeded := * (md .Spec .Replicas ) - mdutil .MaxUnavailable (* md )
484
484
485
- // TODO: v1beta2
486
485
availableReplicas := int32 (0 )
487
486
if md .Status .Deprecated != nil && md .Status .Deprecated .V1Beta1 != nil {
488
487
availableReplicas = md .Status .Deprecated .V1Beta1 .AvailableReplicas
489
488
}
490
489
if availableReplicas >= minReplicasNeeded {
491
- // NOTE: The structure of calculateStatus () does not allow us to update the machinedeployment directly, we can only update the status obj it returns. Ideally, we should change calculateStatus () --> updateStatus() to be consistent with the rest of the code base, until then, we update conditions here.
490
+ // NOTE: The structure of calculateV1Beta1Status () does not allow us to update the machinedeployment directly, we can only update the status obj it returns. Ideally, we should change calculateV1Beta1Status () --> updateStatus() to be consistent with the rest of the code base, until then, we update conditions here.
492
491
v1beta1conditions .MarkTrue (md , clusterv1 .MachineDeploymentAvailableV1Beta1Condition )
493
492
} else {
494
493
v1beta1conditions .MarkFalse (md , clusterv1 .MachineDeploymentAvailableV1Beta1Condition , clusterv1 .WaitingForAvailableMachinesV1Beta1Reason , clusterv1 .ConditionSeverityWarning , "Minimum availability requires %d replicas, current %d available" , minReplicasNeeded , md .Status .AvailableReplicas )
@@ -504,15 +503,15 @@ func (r *Reconciler) syncDeploymentStatus(allMSs []*clusterv1.MachineSet, newMS
504
503
v1beta1conditions .MarkFalse (md , clusterv1 .MachineSetReadyV1Beta1Condition , clusterv1 .WaitingForMachineSetFallbackV1Beta1Reason , clusterv1 .ConditionSeverityInfo , "MachineSet not found" )
505
504
}
506
505
507
- // Set v1beta replica counters on MD status.
506
+ // Set replica counters on MD status.
508
507
setReplicas (md , allMSs )
509
508
510
509
return nil
511
510
}
512
511
513
- // calculateStatus calculates the latest status for the provided deployment by looking into the provided MachineSets.
514
- func calculateStatus (allMSs []* clusterv1.MachineSet , newMS * clusterv1.MachineSet , deployment * clusterv1.MachineDeployment ) clusterv1.MachineDeploymentStatus {
515
- availableReplicas := mdutil .GetAvailableReplicaCountForMachineSets (allMSs )
512
+ // calculateV1Beta1Status calculates the latest status for the provided deployment by looking into the provided MachineSets.
513
+ func calculateV1Beta1Status (allMSs []* clusterv1.MachineSet , newMS * clusterv1.MachineSet , deployment * clusterv1.MachineDeployment ) clusterv1.MachineDeploymentStatus {
514
+ availableReplicas := mdutil .GetV1Beta1AvailableReplicaCountForMachineSets (allMSs )
516
515
totalReplicas := mdutil .GetReplicaCountForMachineSets (allMSs )
517
516
unavailableReplicas := totalReplicas - availableReplicas
518
517
@@ -525,7 +524,7 @@ func calculateStatus(allMSs []*clusterv1.MachineSet, newMS *clusterv1.MachineSet
525
524
// Calculate the label selector. We check the error in the MD reconcile function, ignore here.
526
525
selector , _ := metav1 .LabelSelectorAsSelector (& deployment .Spec .Selector )
527
526
528
- // TODO (v1beta2) Use new replica counters
527
+ // Carry over deprecated v1beta1 conditions if defined.
529
528
var conditions clusterv1.Conditions
530
529
if deployment .Status .Deprecated != nil && deployment .Status .Deprecated .V1Beta1 != nil {
531
530
conditions = deployment .Status .Deprecated .V1Beta1 .Conditions
@@ -540,7 +539,7 @@ func calculateStatus(allMSs []*clusterv1.MachineSet, newMS *clusterv1.MachineSet
540
539
V1Beta1 : & clusterv1.MachineDeploymentV1Beta1DeprecatedStatus {
541
540
Conditions : conditions ,
542
541
UpdatedReplicas : mdutil .GetActualReplicaCountForMachineSets ([]* clusterv1.MachineSet {newMS }),
543
- ReadyReplicas : mdutil .GetReadyReplicaCountForMachineSets (allMSs ),
542
+ ReadyReplicas : mdutil .GetV1Beta1ReadyReplicaCountForMachineSets (allMSs ),
544
543
AvailableReplicas : availableReplicas ,
545
544
UnavailableReplicas : unavailableReplicas ,
546
545
},
0 commit comments