Skip to content

Commit

Permalink
job_endpoint: check spec for all regions (#14519) (#14544)
Browse files Browse the repository at this point in the history
* job_endpoint: check spec for all regions

Co-authored-by: Derek Strickland <1111455+DerekStrickland@users.noreply.github.com>
  • Loading branch information
hc-github-team-nomad-core and DerekStrickland committed Sep 12, 2022
1 parent 9a7cf3e commit 1a4f17d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/14519.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
rpc: check for spec changes in all regions when registering multiregion jobs
```
7 changes: 6 additions & 1 deletion nomad/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,12 @@ func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegis
}

// Check if the job has changed at all
if existingJob == nil || existingJob.SpecChanged(args.Job) {
specChanged, err := j.multiregionSpecChanged(existingJob, args)
if err != nil {
return err
}

if existingJob == nil || specChanged {

// COMPAT(1.1.0): Remove the ServerMeetMinimumVersion check to always set args.Eval
// 0.12.1 introduced atomic eval job registration
Expand Down
9 changes: 9 additions & 0 deletions nomad/job_endpoint_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ func (j *Job) multiVaultNamespaceValidation(
}
return nil
}

// multiregionSpecChanged checks to see if the job spec has changed. If the job is multiregion,
// it checks all regions to determine if any deployed jobs instances have been stopped or
// otherwise differ from the incoming jobspec. Since multiregion jobs require coordinated
// deployments and synchronized job versions across all regions, a change in one requires
// redeployment of all.
func (j *Job) multiregionSpecChanged(existingJob *structs.Job, args *structs.JobRegisterRequest) (bool, error) {
return existingJob.SpecChanged(args.Job), nil
}

0 comments on commit 1a4f17d

Please sign in to comment.