Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Update nomad-jobspec plugin to handle periodic jobs.
Browse files Browse the repository at this point in the history
Nomad periodic jobs don't have an "update" stanza, so we no longer check for canaries for such jobs. We also do not monitor a Nomad evaluation after the job is registered, because not all jobs (namely, periodic jobs) have an evaluation immediately after job registration.
  • Loading branch information
paladin-devops committed Sep 30, 2022
1 parent 4216e5b commit 97d4850
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .changelog/3963.txt
@@ -0,0 +1,3 @@
```release-note:bug
plugin/nomad-jobspec: Fix deployment of periodic Nomad jobs.
```
21 changes: 13 additions & 8 deletions builtin/nomad/jobspec/platform.go
Expand Up @@ -137,11 +137,14 @@ func (p *Platform) resourceJobCreate(
state.Name = result.Name
st.Step(terminal.StatusOK, "Job registration successful")

// Wait on the allocation
// Wait on the allocation. Periodic Nomad jobs will not get an evaluation,
// so we don't monitor an evaluation if we don't have one.
evalID := regResult.EvalID
st.Update("Monitoring evaluation " + evalID)
if err := nomad.NewMonitor(st, client).Monitor(evalID); err != nil {
return err
if evalID != "" {
st.Update("Monitoring evaluation " + evalID)
if err := nomad.NewMonitor(st, client).Monitor(evalID); err != nil {
return err
}
}
st.Step(terminal.StatusOK, "Deployment successfully rolled out!")

Expand Down Expand Up @@ -410,11 +413,13 @@ func (p *Platform) Generation(
return nil, err
}

// If we have canaries, generate random ID, otherwise keep gen ID as job ID
canaryDeployment := false
for _, taskGroup := range job.TaskGroups {
if *taskGroup.Update.Canary > 0 {
canaryDeployment = true
// If we have canaries, generate random ID, otherwise keep gen ID as job ID
if !job.IsPeriodic() {
for _, taskGroup := range job.TaskGroups {
if *taskGroup.Update.Canary > 0 {
canaryDeployment = true
}
}
}

Expand Down

0 comments on commit 97d4850

Please sign in to comment.