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

fix:scale down not available stableRS #735

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 8 additions & 1 deletion utils/replicaset/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@ func CalculateReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS *appsv1.Re
minAvailableReplicaCount := rolloutSpecReplica - MaxUnavailable(rollout)

totalAvailableOlderReplicaCount := GetAvailableReplicaCountForReplicaSets(oldRSs)
scaleDownCount := GetReplicasForScaleDown(newRS) + GetReplicasForScaleDown(stableRS) + totalAvailableOlderReplicaCount - minAvailableReplicaCount
stableRSReplicasForScaleDown := GetReplicasForScaleDown(stableRS)
scaleDownCount := GetReplicasForScaleDown(newRS) + stableRSReplicasForScaleDown + totalAvailableOlderReplicaCount - minAvailableReplicaCount

if scaleDownCount <= 0 && stableRSReplicasForScaleDown == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this works for the scenario you provided, I don't think this is a complete fix, because stableRSReplicasForScaleDown == 0 is just one case and I think it would be possible for stableRSReplicasForScaleDown > 0 and we would still face the problem. E.g. for the initial version, 1 out of 2 pods were available, but the other was CrashLoopBackoff-ing

// if stableRS AvailableReplicas is 0 , container not running rollout replicas to 0
stableRSReplicaCount = stableRSReplicasForScaleDown
return newRSReplicaCount, stableRSReplicaCount
}

if scaleDownCount <= 0 {
// Cannot scale down stableRS or newRS without going below min available replica count
Expand Down
16 changes: 16 additions & 0 deletions utils/replicaset/canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,22 @@ func TestCalculateReplicaCountsForCanary(t *testing.T) {
expectedStableReplicaCount: 10,
expectedCanaryReplicaCount: 2,
},
{
name: "scale down not available stableRS",
rolloutSpecReplicas: 10,
setWeight: 30,
maxSurge: intstr.FromInt(1),
maxUnavailable: intstr.FromInt(0),

stableSpecReplica: 4,
stableAvailableReplica: 0,

canarySpecReplica: 0,
canaryAvailableReplica: 0,

expectedStableReplicaCount: 0,
expectedCanaryReplicaCount: 3,
},
}
for i := range tests {
test := tests[i]
Expand Down