describe a pending deployment with auto_promote accurately
This commit is contained in:
parent
5261c737b2
commit
34230577df
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue