job_endpoint: check spec for all regions (#14519)

* job_endpoint: check spec for all regions
This commit is contained in:
Derek Strickland
2022-09-12 09:24:26 -04:00
committed by GitHub
parent 39a3fd652c
commit 6bca91e749
3 changed files with 18 additions and 1 deletions

3
.changelog/14519.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
rpc: check for spec changes in all regions when registering multiregion jobs
```

View File

@@ -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

View File

@@ -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
}