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

nomad-jobspec plugin periodic and system job fixes #3963

Merged
merged 2 commits into from Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3963.txt
@@ -0,0 +1,3 @@
```release-note:bug
plugin/nomad-jobspec: Fix deployment of periodic and system Nomad jobs.
```
23 changes: 15 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,15 @@ 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.
// Periodic jobs and system jobs currently don't support canaries, so we don't
// do this check if our job fits either case.
if !job.IsPeriodic() && *job.Type != "system" {
for _, taskGroup := range job.TaskGroups {
if *taskGroup.Update.Canary > 0 {
canaryDeployment = true
}
}
}

Expand Down