Skip to content

Commit 6ed0f4e

Browse files
committed
scheduler: DesiredCanaries can be set on every pass safely
The reconcile loop sets `DeploymentState.DesiredCanaries` only on the first pass through the loop and if the job is not paused/pending. In MRD, deployments will make one pass though the loop while "pending", and were not ever getting `DesiredCanaries` set. We can't set it in the initial `DeploymentState` constructor because the first pass through setting up canaries expects it's not there yet. However, this value is static for a given version of a job because it's coming from the update stanza, so it's safe to re-assign the value on subsequent passes.
1 parent 5cb11b7 commit 6ed0f4e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scheduler/reconcile.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,12 @@ func (a *allocReconciler) computeGroup(group string, all allocSet) bool {
428428
strategy := tg.Update
429429
canariesPromoted := dstate != nil && dstate.Promoted
430430
requireCanary := numDestructive != 0 && strategy != nil && len(canaries) < strategy.Canary && !canariesPromoted
431+
if requireCanary {
432+
dstate.DesiredCanaries = strategy.Canary
433+
}
431434
if requireCanary && !a.deploymentPaused && !a.deploymentFailed {
432435
number := strategy.Canary - len(canaries)
433436
desiredChanges.Canary += uint64(number)
434-
if !existingDeployment {
435-
dstate.DesiredCanaries = strategy.Canary
436-
}
437437

438438
for _, name := range nameIndex.NextCanaries(uint(number), canaries, destructive) {
439439
a.result.place = append(a.result.place, allocPlaceResult{

0 commit comments

Comments
 (0)