mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
Add JobModifyIndex
This commit is contained in:
@@ -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{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user