diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 82e7320dd..eb365f83f 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -7003,6 +7003,7 @@ const ( // deployment can be in. DeploymentStatusDescriptionRunning = "Deployment is running" DeploymentStatusDescriptionRunningNeedsPromotion = "Deployment is running but requires promotion" + DeploymentStatusDescriptionRunningAutoPromotion = "Deployment is running pending automatic promotion" DeploymentStatusDescriptionPaused = "Deployment is paused" DeploymentStatusDescriptionSuccessful = "Deployment completed successfully" DeploymentStatusDescriptionStoppedJob = "Cancelled because job is stopped" @@ -7153,6 +7154,19 @@ func (d *Deployment) RequiresPromotion() bool { return false } +// HasAutoPromote determines if any taskgroup is marked auto_promote +func (d *Deployment) HasAutoPromote() bool { + if d == nil || len(d.TaskGroups) == 0 || d.Status != DeploymentStatusRunning { + return false + } + for _, group := range d.TaskGroups { + if group.AutoPromote { + return true + } + } + return false +} + func (d *Deployment) GoString() string { base := fmt.Sprintf("Deployment ID %q for job %q has status %q (%v):", d.ID, d.JobID, d.Status, d.StatusDescription) for group, state := range d.TaskGroups { diff --git a/scheduler/reconcile.go b/scheduler/reconcile.go index 871cceede..65262ff93 100644 --- a/scheduler/reconcile.go +++ b/scheduler/reconcile.go @@ -218,7 +218,11 @@ func (a *allocReconciler) Compute() *reconcileResults { // Set the description of a created deployment if d := a.result.deployment; d != nil { if d.RequiresPromotion() { - d.StatusDescription = structs.DeploymentStatusDescriptionRunningNeedsPromotion + if d.HasAutoPromote() { + d.StatusDescription = structs.DeploymentStatusDescriptionRunningAutoPromotion + } else { + d.StatusDescription = structs.DeploymentStatusDescriptionRunningNeedsPromotion + } } }