From 6ffd842a88b58ed113d269e7998cbbb5b3200ff2 Mon Sep 17 00:00:00 2001 From: Conor Mongey Date: Fri, 23 Apr 2021 00:48:02 +0100 Subject: [PATCH] Fix panic when a job without update stanza fails deployment Currently levant panics if there's a failed deployment for a job without an update stanza. --- levant/deploy.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/levant/deploy.go b/levant/deploy.go index 01b0c33eb..1295914ae 100644 --- a/levant/deploy.go +++ b/levant/deploy.go @@ -183,16 +183,18 @@ func (l *levantDeployment) deploy() (success bool) { log.Error().Err(err).Msgf("levant/deploy: unable to query deployment %s for auto-revert check", depID) return } - - // If the job is not a canary job, then run the auto-revert checker, the - // current checking mechanism is slightly hacky and should be updated. - // The reason for this is currently the config.Job is populate from the - // rendered job and so a user could potentially not set canary meaning - // the field shows a null. - if l.config.Template.Job.Update.Canary == nil { - l.checkAutoRevert(dep) - } else if *l.config.Template.Job.Update.Canary == 0 { - l.checkAutoRevert(dep) + + if l.config.Template.Job.Update != nil { + // If the job is not a canary job, then run the auto-revert checker, the + // current checking mechanism is slightly hacky and should be updated. + // The reason for this is currently the config.Job is populates from the + // rendered job and so a user could potentially not set canary meaning + // the field shows a null. + if l.config.Template.Job.Update.Canary == nil { + l.checkAutoRevert(dep) + } else if *l.config.Template.Job.Update.Canary == 0 { + l.checkAutoRevert(dep) + } } case nomad.JobTypeBatch: