From 6ed0f4e56419f39dee033d632cfa45457fe5f566 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Fri, 17 Jul 2020 11:22:21 -0400 Subject: [PATCH] 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. --- scheduler/reconcile.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scheduler/reconcile.go b/scheduler/reconcile.go index e41036268..31bed702d 100644 --- a/scheduler/reconcile.go +++ b/scheduler/reconcile.go @@ -428,12 +428,12 @@ func (a *allocReconciler) computeGroup(group string, all allocSet) bool { strategy := tg.Update canariesPromoted := dstate != nil && dstate.Promoted requireCanary := numDestructive != 0 && strategy != nil && len(canaries) < strategy.Canary && !canariesPromoted + if requireCanary { + dstate.DesiredCanaries = strategy.Canary + } if requireCanary && !a.deploymentPaused && !a.deploymentFailed { number := strategy.Canary - len(canaries) desiredChanges.Canary += uint64(number) - if !existingDeployment { - dstate.DesiredCanaries = strategy.Canary - } for _, name := range nameIndex.NextCanaries(uint(number), canaries, destructive) { a.result.place = append(a.result.place, allocPlaceResult{