Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Refine MachineDeployment v1beta2 available condition #11501

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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