Skip to content

Commit

Permalink
Fix panic when a job without update stanza fails deployment
Browse files Browse the repository at this point in the history
Currently levant panics if there's a failed deployment for a job without
an update stanza.
  • Loading branch information
Mongey committed Apr 22, 2021
1 parent e48c439 commit 6ffd842
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions levant/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6ffd842

Please sign in to comment.