Skip to content

Commit

Permalink
Allow job Version to start at non-zero value
Browse files Browse the repository at this point in the history
Stop coercing version of new job to 0 in the state_store, so that we can add
regions to a multi-region deployment. Send new version, rather than existing
version, to MRD to accomodate version-choosing logic changes in ENT.

Co-authored-by: Chris Baker <1675087+cgbaker@users.noreply.github.com>
  • Loading branch information
tgross and cgbaker committed Oct 12, 2020
1 parent c14c616 commit 4278413
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions nomad/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegis

// Submit a multiregion job to other regions (enterprise only).
// The job will have its region interpolated.
var existingVersion uint64
var newVersion uint64
if existingJob != nil {
existingVersion = existingJob.Version
newVersion = existingJob.Version + 1
}
isRunner, err := j.multiregionRegister(args, reply, existingVersion)
isRunner, err := j.multiregionRegister(args, reply, newVersion)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion nomad/job_endpoint_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (j *Job) enforceSubmitJob(override bool, job *structs.Job) (error, error) {
}

// multiregionRegister is used to send a job across multiple regions
func (j *Job) multiregionRegister(args *structs.JobRegisterRequest, reply *structs.JobRegisterResponse, existingVersion uint64) (bool, error) {
func (j *Job) multiregionRegister(args *structs.JobRegisterRequest, reply *structs.JobRegisterResponse, newVersion uint64) (bool, error) {
return false, nil
}

Expand Down
1 change: 0 additions & 1 deletion nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,6 @@ func (s *StateStore) upsertJobImpl(index uint64, job *structs.Job, keepVersion b
job.CreateIndex = index
job.ModifyIndex = index
job.JobModifyIndex = index
job.Version = 0

if err := s.setJobStatus(index, txn, job, false, ""); err != nil {
return fmt.Errorf("setting job status for %q failed: %v", job.ID, err)
Expand Down

0 comments on commit 4278413

Please sign in to comment.