From 28dbf73358cd90631094828cd3a43bbcb1a52711 Mon Sep 17 00:00:00 2001 From: Lang Martin Date: Tue, 21 May 2019 13:02:59 -0400 Subject: [PATCH] deployment_watcher auto promote iff every task group is auto promotable --- nomad/deploymentwatcher/deployment_watcher.go | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/nomad/deploymentwatcher/deployment_watcher.go b/nomad/deploymentwatcher/deployment_watcher.go index 4ce7876ef..e41fa2054 100644 --- a/nomad/deploymentwatcher/deployment_watcher.go +++ b/nomad/deploymentwatcher/deployment_watcher.go @@ -272,43 +272,26 @@ func (w *deploymentWatcher) autoPromoteDeployment(allocs []*structs.AllocListStu return nil } - // Find the promotable groups - groups := []string{} - -TASKGROUP: - for tk, tv := range d.TaskGroups { + // AutoPromote iff every task group is marked auto_promote and is healthy. The whole + // job version has been incremented, so we promote together. See also AutoRevert + for _, tv := range d.TaskGroups { if !tv.AutoPromote || tv.DesiredCanaries != len(tv.PlacedCanaries) { - continue + return nil } // Find the health status of each canary for _, c := range tv.PlacedCanaries { for _, a := range allocs { if c == a.ID && !a.DeploymentStatus.IsHealthy() { - continue TASKGROUP + return nil } } } - - groups = append(groups, tk) - } - - if len(groups) == 0 { - return nil - } - - // Create the request - req := structs.DeploymentPromoteRequest{DeploymentID: d.GetID()} - if len(groups) == len(d.TaskGroups) { - req.All = true - } else { - req.All = false - req.Groups = groups } // Send the request _, err := w.upsertDeploymentPromotion(&structs.ApplyDeploymentPromoteRequest{ - DeploymentPromoteRequest: req, + DeploymentPromoteRequest: structs.DeploymentPromoteRequest{DeploymentID: d.GetID(), All: true}, Eval: w.getEval(), }) return err