Skip to content

Commit

Permalink
Merge pull request #11501 from fabriziopandini/refine-v1beta2-md-avai…
Browse files Browse the repository at this point in the history
…lable

🌱 Refine MachineDeployment v1beta2 available condition
  • Loading branch information
k8s-ci-robot authored Nov 28, 2024
2 parents 93b4aac + b53b896 commit f948999
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ func setAvailableCondition(_ context.Context, machineDeployment *clusterv1.Machi
if machineDeployment.Spec.Strategy != nil && mdutil.IsRollingUpdate(machineDeployment) && machineDeployment.Spec.Strategy.RollingUpdate != nil {
message += fmt.Sprintf(" (spec.strategy.rollout.maxUnavailable is %s, spec.replicas is %d)", machineDeployment.Spec.Strategy.RollingUpdate.MaxUnavailable, *machineDeployment.Spec.Replicas)
}

if !machineDeployment.DeletionTimestamp.IsZero() {
message = "Deletion in progress"
}
v1beta2conditions.Set(machineDeployment, metav1.Condition{
Type: clusterv1.MachineDeploymentAvailableV1Beta2Condition,
Status: metav1.ConditionFalse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,32 @@ func Test_setAvailableCondition(t *testing.T) {
Message: "3 available replicas, at least 4 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 5)",
},
},
{
name: "When deleting, don't show required replicas",
machineDeployment: &clusterv1.MachineDeployment{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: ptr.To(metav1.Now()),
},
Spec: clusterv1.MachineDeploymentSpec{
Replicas: ptr.To(int32(5)),
Strategy: &clusterv1.MachineDeploymentStrategy{
Type: clusterv1.RollingUpdateMachineDeploymentStrategyType,
RollingUpdate: &clusterv1.MachineRollingUpdateDeployment{
MaxSurge: ptr.To(intstr.FromInt32(1)),
MaxUnavailable: ptr.To(intstr.FromInt32(1)),
},
},
},
Status: clusterv1.MachineDeploymentStatus{V1Beta2: &clusterv1.MachineDeploymentV1Beta2Status{AvailableReplicas: ptr.To(int32(0))}},
},
getAndAdoptMachineSetsForDeploymentSucceeded: true,
expectCondition: metav1.Condition{
Type: clusterv1.MachineDeploymentAvailableV1Beta2Condition,
Status: metav1.ConditionFalse,
Reason: clusterv1.MachineDeploymentNotAvailableV1Beta2Reason,
Message: "Deletion in progress",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit f948999

Please sign in to comment.