From 40990de65822d71c41a28075ae35522c3f24afa6 Mon Sep 17 00:00:00 2001 From: Joseph Rajewski <83741749+paladin-devops@users.noreply.github.com> Date: Fri, 30 Sep 2022 13:25:17 -0400 Subject: [PATCH] Update nomad-jobspec plugin to handle periodic jobs. 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. --- builtin/nomad/jobspec/platform.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/builtin/nomad/jobspec/platform.go b/builtin/nomad/jobspec/platform.go index 6c9077ecdc2..8f4effcded3 100644 --- a/builtin/nomad/jobspec/platform.go +++ b/builtin/nomad/jobspec/platform.go @@ -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!") @@ -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 + } } }