diff --git a/nomad/job_endpoint.go b/nomad/job_endpoint.go index f57b980364f..e2755c0da14 100644 --- a/nomad/job_endpoint.go +++ b/nomad/job_endpoint.go @@ -395,6 +395,12 @@ func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegis args.Job.JobModifyIndex = reply.JobModifyIndex if eval == nil { + // For dispatch jobs we return early, so we need to drop regions + // here rather than after eval for deployments is kicked off + err = j.multiregionDrop(args, reply) + if err != nil { + return err + } return nil } @@ -424,6 +430,14 @@ func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegis if err != nil { return err } + // We drop any unwanted regions only once we know all jobs have + // been registered and we've kicked off the deployment. This keeps + // dropping regions close in semantics to dropping task groups in + // single-region deployments + err = j.multiregionDrop(args, reply) + if err != nil { + return err + } } return nil diff --git a/nomad/job_endpoint_oss.go b/nomad/job_endpoint_oss.go index b7ad70b1ba7..9d36255c844 100644 --- a/nomad/job_endpoint_oss.go +++ b/nomad/job_endpoint_oss.go @@ -25,6 +25,12 @@ func (j *Job) multiregionStart(args *structs.JobRegisterRequest, reply *structs. return nil } +// multiregionDrop is used to deregister regions from a previous version of the +// job that are no longer in use +func (j *Job) multiregionDrop(args *structs.JobRegisterRequest, reply *structs.JobRegisterResponse) error { + return nil +} + // interpolateMultiregionFields interpolates a job for a specific region func (j *Job) interpolateMultiregionFields(args *structs.JobPlanRequest) error { return nil