Skip to content

Commit

Permalink
job_endpoint: check spec for all regions (#14519)
Browse files Browse the repository at this point in the history
* job_endpoint: check spec for all regions
  • Loading branch information
DerekStrickland committed Sep 12, 2022
1 parent 39a3fd6 commit 6bca91e
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 @@ -349,7 +349,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 @@ -38,3 +38,12 @@ func (j *Job) multiregionStop(job *structs.Job, args *structs.JobDeregisterReque
func (j *Job) interpolateMultiregionFields(args *structs.JobPlanRequest) error {
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 6bca91e

Please sign in to comment.