From acf8f6760e432f1a61f6b1e6867455cb137eb8d8 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Sat, 12 Aug 2017 15:50:51 -0700 Subject: [PATCH] Deployment desc when no stable job and autorevert This PR adds a specialized description when the job has autorevert set and there is no job to revert to. --- nomad/deploymentwatcher/deployment_watcher.go | 4 ++++ nomad/structs/structs.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/nomad/deploymentwatcher/deployment_watcher.go b/nomad/deploymentwatcher/deployment_watcher.go index f4f4c9674054..2fdb05611189 100644 --- a/nomad/deploymentwatcher/deployment_watcher.go +++ b/nomad/deploymentwatcher/deployment_watcher.go @@ -257,6 +257,8 @@ func (w *deploymentWatcher) FailDeployment( if rollbackJob != nil { desc = structs.DeploymentStatusDescriptionRollback(desc, rollbackJob.Version) + } else { + desc = structs.DeploymentStatusDescriptionNoRollbackTarget(desc) } } @@ -361,6 +363,8 @@ func (w *deploymentWatcher) watch() { // version N if j != nil { desc = structs.DeploymentStatusDescriptionRollback(desc, j.Version) + } else { + desc = structs.DeploymentStatusDescriptionNoRollbackTarget(desc) } } diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index ab615c8623e1..814115f5ad85 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -4117,6 +4117,12 @@ func DeploymentStatusDescriptionRollback(baseDescription string, jobVersion uint return fmt.Sprintf("%s - rolling back to job version %d", baseDescription, jobVersion) } +// DeploymentStatusDescriptionNoRollbackTarget is used to get the status description of +// a deployment when there is no target to rollback to but autorevet is desired. +func DeploymentStatusDescriptionNoRollbackTarget(baseDescription string) string { + return fmt.Sprintf("%s - no stable job version to auto revert to", baseDescription) +} + // Deployment is the object that represents a job deployment which is used to // transition a job between versions. type Deployment struct {