Skip to content

Commit

Permalink
Add JobModifyIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Jan 12, 2016
1 parent 875bf47 commit 47fbfd3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions nomad/job_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ func TestJobEndpoint_GetJob(t *testing.T) {
}
job.CreateIndex = resp.JobModifyIndex
job.ModifyIndex = resp.JobModifyIndex
job.JobModifyIndex = resp.JobModifyIndex

// Lookup the job
get := &structs.JobSpecificRequest{
Expand Down
7 changes: 4 additions & 3 deletions nomad/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ func Job() *structs.Job {
Meta: map[string]string{
"owner": "armon",
},
Status: structs.JobStatusPending,
CreateIndex: 42,
ModifyIndex: 99,
Status: structs.JobStatusPending,
CreateIndex: 42,
ModifyIndex: 99,
JobModifyIndex: 99,
}
job.InitFields()
return job
Expand Down
2 changes: 2 additions & 0 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ func (s *StateStore) UpsertJob(index uint64, job *structs.Job) error {
if existing != nil {
job.CreateIndex = existing.(*structs.Job).CreateIndex
job.ModifyIndex = index
job.JobModifyIndex = index

// Compute the job status
var err error
Expand All @@ -305,6 +306,7 @@ func (s *StateStore) UpsertJob(index uint64, job *structs.Job) error {
} else {
job.CreateIndex = index
job.ModifyIndex = index
job.JobModifyIndex = index

// If we are inserting the job for the first time, we don't need to
// calculate the jobs status as it is known.
Expand Down
5 changes: 3 additions & 2 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,9 @@ type Job struct {
StatusDescription string

// Raft Indexes
CreateIndex uint64
ModifyIndex uint64
CreateIndex uint64
ModifyIndex uint64
JobModifyIndex uint64
}

// InitFields is used to initialize fields in the Job. This should be called
Expand Down
5 changes: 1 addition & 4 deletions scheduler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ func diffAllocs(job *structs.Job, taintedNodes map[string]bool,
}

// If the definition is updated we need to update
// XXX: This is an extremely conservative approach. We can check
// if the job definition has changed in a way that affects
// this allocation and potentially ignore it.
if job.ModifyIndex != exist.Job.ModifyIndex {
if job.JobModifyIndex != exist.Job.JobModifyIndex {
result.update = append(result.update, allocTuple{
Name: name,
TaskGroup: tg,
Expand Down
4 changes: 2 additions & 2 deletions scheduler/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestDiffAllocs(t *testing.T) {
// The "old" job has a previous modify index
oldJob := new(structs.Job)
*oldJob = *job
oldJob.ModifyIndex -= 1
oldJob.JobModifyIndex -= 1

tainted := map[string]bool{
"dead": true,
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestDiffSystemAllocs(t *testing.T) {
// The "old" job has a previous modify index
oldJob := new(structs.Job)
*oldJob = *job
oldJob.ModifyIndex -= 1
oldJob.JobModifyIndex -= 1

tainted := map[string]bool{
"dead": true,
Expand Down

0 comments on commit 47fbfd3

Please sign in to comment.