describe a pending deployment with auto_promote accurately

This commit is contained in:
Lang Martin 2019-05-17 17:53:27 -04:00
parent 5261c737b2
commit 34230577df
2 changed files with 19 additions and 1 deletions

View File

@ -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 {

View File

@ -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
}
}
}