diff --git a/api/allocations.go b/api/allocations.go index c01cbfc45b9..f23b835513b 100644 --- a/api/allocations.go +++ b/api/allocations.go @@ -95,6 +95,7 @@ type Allocation struct { ModifyIndex uint64 AllocModifyIndex uint64 CreateTime int64 + ModifyTime int64 } // AllocationMetric is used to deserialize allocation metrics. @@ -132,11 +133,12 @@ type AllocationListStub struct { CreateIndex uint64 ModifyIndex uint64 CreateTime int64 + ModifyTime int64 } // AllocDeploymentStatus captures the status of the allocation as part of the // deployment. This can include things like if the allocation has been marked as -// heatlhy. +// healthy. type AllocDeploymentStatus struct { Healthy *bool ModifyIndex uint64 diff --git a/nomad/node_endpoint.go b/nomad/node_endpoint.go index a8778216ffd..5f3574c7d69 100644 --- a/nomad/node_endpoint.go +++ b/nomad/node_endpoint.go @@ -774,6 +774,11 @@ func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.Gene return fmt.Errorf("must update at least one allocation") } + // Update modified timestamp for client initiated allocation updates + now := time.Now().UTC().UnixNano() + for _, alloc := range args.Alloc { + alloc.ModifyTime = now + } // Add this to the batch n.updatesLock.Lock() n.updates = append(n.updates, args.Alloc...) diff --git a/nomad/node_endpoint_test.go b/nomad/node_endpoint_test.go index 772a40e3e04..e8e00dbe52f 100644 --- a/nomad/node_endpoint_test.go +++ b/nomad/node_endpoint_test.go @@ -1406,8 +1406,10 @@ func TestClientEndpoint_GetAllocs_Blocking(t *testing.T) { node.ModifyIndex = resp.Index // Inject fake evaluations async + now := time.Now().UTC().UnixNano() alloc := mock.Alloc() alloc.NodeID = node.ID + alloc.ModifyTime = now state := s1.fsm.State() state.UpsertJobSummary(99, mock.JobSummary(alloc.JobID)) start := time.Now() @@ -1445,6 +1447,10 @@ func TestClientEndpoint_GetAllocs_Blocking(t *testing.T) { t.Fatalf("bad: %#v", resp2.Allocs) } + if resp2.Allocs[0].ModifyTime != now { + t.Fatalf("Invalid modify time %v", resp2.Allocs[0].ModifyTime) + } + // Alloc updates fire watches time.AfterFunc(100*time.Millisecond, func() { allocUpdate := mock.Alloc() @@ -1536,6 +1542,10 @@ func TestClientEndpoint_UpdateAlloc(t *testing.T) { if out.ClientStatus != structs.AllocClientStatusFailed { t.Fatalf("Bad: %#v", out) } + + if out.ModifyTime <= 0 { + t.Fatalf("must have valid modify time but was %v", out.ModifyTime) + } } func TestClientEndpoint_BatchUpdate(t *testing.T) { diff --git a/nomad/plan_apply.go b/nomad/plan_apply.go index 9e82c54f688..5d2c29bcfc9 100644 --- a/nomad/plan_apply.go +++ b/nomad/plan_apply.go @@ -150,6 +150,7 @@ func (s *Server) applyPlan(plan *structs.Plan, result *structs.PlanResult, snap if alloc.CreateTime == 0 { alloc.CreateTime = now } + alloc.ModifyTime = now } // Dispatch the Raft transaction diff --git a/nomad/plan_apply_test.go b/nomad/plan_apply_test.go index f4341d49c1a..7d3195d9224 100644 --- a/nomad/plan_apply_test.go +++ b/nomad/plan_apply_test.go @@ -147,6 +147,16 @@ func TestPlanApply_applyPlan(t *testing.T) { t.Fatalf("missing alloc") } + if out.CreateTime <= 0 { + t.Fatalf("invalid create time %v", out.CreateTime) + } + if out.ModifyTime <= 0 { + t.Fatalf("invalid modify time %v", out.CreateTime) + } + if out.CreateTime != out.ModifyTime { + t.Fatalf("create time %v modify time %v must be equal", out.CreateTime, out.ModifyTime) + } + // Lookup the new deployment dout, err := fsmState.DeploymentByID(ws, plan.Deployment.ID) if err != nil { @@ -226,6 +236,10 @@ func TestPlanApply_applyPlan(t *testing.T) { t.Fatalf("missing job") } + if out.ModifyTime <= 0 { + t.Fatalf("must have valid modify time but was %v", out.ModifyTime) + } + // Lookup the allocation out, err = s1.fsm.State().AllocByID(ws, alloc2.ID) if err != nil { diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 9214679d80b..5c2989b69f8 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -1718,6 +1718,9 @@ func (s *StateStore) nestedUpdateAllocFromClient(txn *memdb.Txn, index uint64, a // Update the modify index copyAlloc.ModifyIndex = index + // Update the modify time + copyAlloc.ModifyTime = alloc.ModifyTime + if err := s.updateDeploymentWithAlloc(index, copyAlloc, exist, txn); err != nil { return fmt.Errorf("error updating deployment: %v", err) } diff --git a/nomad/structs/structs.generated.go b/nomad/structs/structs.generated.go index 5eb7b8d9bbd..8e65ba3d6e0 100644 --- a/nomad/structs/structs.generated.go +++ b/nomad/structs/structs.generated.go @@ -53946,14 +53946,14 @@ func (x *Allocation) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [24]bool + var yyq2 [25]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(24) + r.EncodeArrayStart(25) } else { - yynn2 = 24 + yynn2 = 25 for _, b := range yyq2 { if b { yynn2++ @@ -54424,6 +54424,25 @@ func (x *Allocation) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeInt(int64(x.CreateTime)) } } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem100) + yym76 := z.EncBinary() + _ = yym76 + if false { + } else { + r.EncodeInt(int64(x.ModifyTime)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey100) + r.EncodeString(codecSelferC_UTF8100, string("ModifyTime")) + z.EncSendContainerState(codecSelfer_containerMapValue100) + yym77 := z.EncBinary() + _ = yym77 + if false { + } else { + r.EncodeInt(int64(x.ModifyTime)) + } + } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayEnd100) } else { @@ -54768,6 +54787,18 @@ func (x *Allocation) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { *((*int64)(yyv45)) = int64(r.DecodeInt(64)) } } + case "ModifyTime": + if r.TryDecodeAsNil() { + x.ModifyTime = 0 + } else { + yyv47 := &x.ModifyTime + yym48 := z.DecBinary() + _ = yym48 + if false { + } else { + *((*int64)(yyv47)) = int64(r.DecodeInt(64)) + } + } default: z.DecStructFieldNotFound(-1, yys3) } // end switch yys3 @@ -54779,16 +54810,16 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer100 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj47 int - var yyb47 bool - var yyhl47 bool = l >= 0 - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + var yyj49 int + var yyb49 bool + var yyhl49 bool = l >= 0 + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54796,21 +54827,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.ID = "" } else { - yyv48 := &x.ID - yym49 := z.DecBinary() - _ = yym49 + yyv50 := &x.ID + yym51 := z.DecBinary() + _ = yym51 if false { } else { - *((*string)(yyv48)) = r.DecodeString() + *((*string)(yyv50)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54818,21 +54849,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Namespace = "" } else { - yyv50 := &x.Namespace - yym51 := z.DecBinary() - _ = yym51 + yyv52 := &x.Namespace + yym53 := z.DecBinary() + _ = yym53 if false { } else { - *((*string)(yyv50)) = r.DecodeString() + *((*string)(yyv52)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54840,21 +54871,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.EvalID = "" } else { - yyv52 := &x.EvalID - yym53 := z.DecBinary() - _ = yym53 + yyv54 := &x.EvalID + yym55 := z.DecBinary() + _ = yym55 if false { } else { - *((*string)(yyv52)) = r.DecodeString() + *((*string)(yyv54)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54862,21 +54893,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Name = "" } else { - yyv54 := &x.Name - yym55 := z.DecBinary() - _ = yym55 + yyv56 := &x.Name + yym57 := z.DecBinary() + _ = yym57 if false { } else { - *((*string)(yyv54)) = r.DecodeString() + *((*string)(yyv56)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54884,21 +54915,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.NodeID = "" } else { - yyv56 := &x.NodeID - yym57 := z.DecBinary() - _ = yym57 + yyv58 := &x.NodeID + yym59 := z.DecBinary() + _ = yym59 if false { } else { - *((*string)(yyv56)) = r.DecodeString() + *((*string)(yyv58)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54906,21 +54937,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.JobID = "" } else { - yyv58 := &x.JobID - yym59 := z.DecBinary() - _ = yym59 + yyv60 := &x.JobID + yym61 := z.DecBinary() + _ = yym61 if false { } else { - *((*string)(yyv58)) = r.DecodeString() + *((*string)(yyv60)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54935,13 +54966,13 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.Job.CodecDecodeSelf(d) } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54949,21 +54980,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.TaskGroup = "" } else { - yyv61 := &x.TaskGroup - yym62 := z.DecBinary() - _ = yym62 + yyv63 := &x.TaskGroup + yym64 := z.DecBinary() + _ = yym64 if false { } else { - *((*string)(yyv61)) = r.DecodeString() + *((*string)(yyv63)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54978,13 +55009,13 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.Resources.CodecDecodeSelf(d) } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -54999,13 +55030,13 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.SharedResources.CodecDecodeSelf(d) } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55013,21 +55044,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.TaskResources = nil } else { - yyv65 := &x.TaskResources - yym66 := z.DecBinary() - _ = yym66 + yyv67 := &x.TaskResources + yym68 := z.DecBinary() + _ = yym68 if false { } else { - h.decMapstringPtrtoResources((*map[string]*Resources)(yyv65), d) + h.decMapstringPtrtoResources((*map[string]*Resources)(yyv67), d) } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55042,13 +55073,13 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.Metrics.CodecDecodeSelf(d) } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55056,21 +55087,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.DesiredStatus = "" } else { - yyv68 := &x.DesiredStatus - yym69 := z.DecBinary() - _ = yym69 + yyv70 := &x.DesiredStatus + yym71 := z.DecBinary() + _ = yym71 if false { } else { - *((*string)(yyv68)) = r.DecodeString() + *((*string)(yyv70)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55078,21 +55109,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.DesiredDescription = "" } else { - yyv70 := &x.DesiredDescription - yym71 := z.DecBinary() - _ = yym71 + yyv72 := &x.DesiredDescription + yym73 := z.DecBinary() + _ = yym73 if false { } else { - *((*string)(yyv70)) = r.DecodeString() + *((*string)(yyv72)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55100,21 +55131,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.ClientStatus = "" } else { - yyv72 := &x.ClientStatus - yym73 := z.DecBinary() - _ = yym73 + yyv74 := &x.ClientStatus + yym75 := z.DecBinary() + _ = yym75 if false { } else { - *((*string)(yyv72)) = r.DecodeString() + *((*string)(yyv74)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55122,21 +55153,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.ClientDescription = "" } else { - yyv74 := &x.ClientDescription - yym75 := z.DecBinary() - _ = yym75 + yyv76 := &x.ClientDescription + yym77 := z.DecBinary() + _ = yym77 if false { } else { - *((*string)(yyv74)) = r.DecodeString() + *((*string)(yyv76)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55144,21 +55175,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.TaskStates = nil } else { - yyv76 := &x.TaskStates - yym77 := z.DecBinary() - _ = yym77 + yyv78 := &x.TaskStates + yym79 := z.DecBinary() + _ = yym79 if false { } else { - h.decMapstringPtrtoTaskState((*map[string]*TaskState)(yyv76), d) + h.decMapstringPtrtoTaskState((*map[string]*TaskState)(yyv78), d) } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55166,21 +55197,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.PreviousAllocation = "" } else { - yyv78 := &x.PreviousAllocation - yym79 := z.DecBinary() - _ = yym79 + yyv80 := &x.PreviousAllocation + yym81 := z.DecBinary() + _ = yym81 if false { } else { - *((*string)(yyv78)) = r.DecodeString() + *((*string)(yyv80)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55188,21 +55219,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.DeploymentID = "" } else { - yyv80 := &x.DeploymentID - yym81 := z.DecBinary() - _ = yym81 + yyv82 := &x.DeploymentID + yym83 := z.DecBinary() + _ = yym83 if false { } else { - *((*string)(yyv80)) = r.DecodeString() + *((*string)(yyv82)) = r.DecodeString() } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55217,13 +55248,13 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.DeploymentStatus.CodecDecodeSelf(d) } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55231,21 +55262,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.CreateIndex = 0 } else { - yyv83 := &x.CreateIndex - yym84 := z.DecBinary() - _ = yym84 + yyv85 := &x.CreateIndex + yym86 := z.DecBinary() + _ = yym86 if false { } else { - *((*uint64)(yyv83)) = uint64(r.DecodeUint(64)) + *((*uint64)(yyv85)) = uint64(r.DecodeUint(64)) } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55253,21 +55284,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.ModifyIndex = 0 } else { - yyv85 := &x.ModifyIndex - yym86 := z.DecBinary() - _ = yym86 + yyv87 := &x.ModifyIndex + yym88 := z.DecBinary() + _ = yym88 if false { } else { - *((*uint64)(yyv85)) = uint64(r.DecodeUint(64)) + *((*uint64)(yyv87)) = uint64(r.DecodeUint(64)) } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55275,21 +55306,21 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.AllocModifyIndex = 0 } else { - yyv87 := &x.AllocModifyIndex - yym88 := z.DecBinary() - _ = yym88 + yyv89 := &x.AllocModifyIndex + yym90 := z.DecBinary() + _ = yym90 if false { } else { - *((*uint64)(yyv87)) = uint64(r.DecodeUint(64)) + *((*uint64)(yyv89)) = uint64(r.DecodeUint(64)) } } - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55297,26 +55328,48 @@ func (x *Allocation) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.CreateTime = 0 } else { - yyv89 := &x.CreateTime - yym90 := z.DecBinary() - _ = yym90 + yyv91 := &x.CreateTime + yym92 := z.DecBinary() + _ = yym92 + if false { + } else { + *((*int64)(yyv91)) = int64(r.DecodeInt(64)) + } + } + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l + } else { + yyb49 = r.CheckBreak() + } + if yyb49 { + z.DecSendContainerState(codecSelfer_containerArrayEnd100) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem100) + if r.TryDecodeAsNil() { + x.ModifyTime = 0 + } else { + yyv93 := &x.ModifyTime + yym94 := z.DecBinary() + _ = yym94 if false { } else { - *((*int64)(yyv89)) = int64(r.DecodeInt(64)) + *((*int64)(yyv93)) = int64(r.DecodeInt(64)) } } for { - yyj47++ - if yyhl47 { - yyb47 = yyj47 > l + yyj49++ + if yyhl49 { + yyb49 = yyj49 > l } else { - yyb47 = r.CheckBreak() + yyb49 = r.CheckBreak() } - if yyb47 { + if yyb49 { break } z.DecSendContainerState(codecSelfer_containerArrayElem100) - z.DecStructFieldNotFound(yyj47-1, "") + z.DecStructFieldNotFound(yyj49-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd100) } @@ -55335,14 +55388,14 @@ func (x *AllocListStub) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [16]bool + var yyq2 [17]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(16) + r.EncodeArrayStart(17) } else { - yynn2 = 16 + yynn2 = 17 for _, b := range yyq2 { if b { yynn2++ @@ -55661,6 +55714,25 @@ func (x *AllocListStub) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeInt(int64(x.CreateTime)) } } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem100) + yym52 := z.EncBinary() + _ = yym52 + if false { + } else { + r.EncodeInt(int64(x.ModifyTime)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey100) + r.EncodeString(codecSelferC_UTF8100, string("ModifyTime")) + z.EncSendContainerState(codecSelfer_containerMapValue100) + yym53 := z.EncBinary() + _ = yym53 + if false { + } else { + r.EncodeInt(int64(x.ModifyTime)) + } + } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayEnd100) } else { @@ -55913,6 +55985,18 @@ func (x *AllocListStub) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { *((*int64)(yyv33)) = int64(r.DecodeInt(64)) } } + case "ModifyTime": + if r.TryDecodeAsNil() { + x.ModifyTime = 0 + } else { + yyv35 := &x.ModifyTime + yym36 := z.DecBinary() + _ = yym36 + if false { + } else { + *((*int64)(yyv35)) = int64(r.DecodeInt(64)) + } + } default: z.DecStructFieldNotFound(-1, yys3) } // end switch yys3 @@ -55924,16 +56008,16 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer100 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj35 int - var yyb35 bool - var yyhl35 bool = l >= 0 - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + var yyj37 int + var yyb37 bool + var yyhl37 bool = l >= 0 + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -55941,29 +56025,7 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.ID = "" } else { - yyv36 := &x.ID - yym37 := z.DecBinary() - _ = yym37 - if false { - } else { - *((*string)(yyv36)) = r.DecodeString() - } - } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l - } else { - yyb35 = r.CheckBreak() - } - if yyb35 { - z.DecSendContainerState(codecSelfer_containerArrayEnd100) - return - } - z.DecSendContainerState(codecSelfer_containerArrayElem100) - if r.TryDecodeAsNil() { - x.EvalID = "" - } else { - yyv38 := &x.EvalID + yyv38 := &x.ID yym39 := z.DecBinary() _ = yym39 if false { @@ -55971,21 +56033,21 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { *((*string)(yyv38)) = r.DecodeString() } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.Name = "" + x.EvalID = "" } else { - yyv40 := &x.Name + yyv40 := &x.EvalID yym41 := z.DecBinary() _ = yym41 if false { @@ -55993,21 +56055,21 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { *((*string)(yyv40)) = r.DecodeString() } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.NodeID = "" + x.Name = "" } else { - yyv42 := &x.NodeID + yyv42 := &x.Name yym43 := z.DecBinary() _ = yym43 if false { @@ -56015,21 +56077,21 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { *((*string)(yyv42)) = r.DecodeString() } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.JobID = "" + x.NodeID = "" } else { - yyv44 := &x.JobID + yyv44 := &x.NodeID yym45 := z.DecBinary() _ = yym45 if false { @@ -56037,65 +56099,65 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { *((*string)(yyv44)) = r.DecodeString() } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.JobVersion = 0 + x.JobID = "" } else { - yyv46 := &x.JobVersion + yyv46 := &x.JobID yym47 := z.DecBinary() _ = yym47 if false { } else { - *((*uint64)(yyv46)) = uint64(r.DecodeUint(64)) + *((*string)(yyv46)) = r.DecodeString() } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.TaskGroup = "" + x.JobVersion = 0 } else { - yyv48 := &x.TaskGroup + yyv48 := &x.JobVersion yym49 := z.DecBinary() _ = yym49 if false { } else { - *((*string)(yyv48)) = r.DecodeString() + *((*uint64)(yyv48)) = uint64(r.DecodeUint(64)) } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.DesiredStatus = "" + x.TaskGroup = "" } else { - yyv50 := &x.DesiredStatus + yyv50 := &x.TaskGroup yym51 := z.DecBinary() _ = yym51 if false { @@ -56103,21 +56165,21 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { *((*string)(yyv50)) = r.DecodeString() } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.DesiredDescription = "" + x.DesiredStatus = "" } else { - yyv52 := &x.DesiredDescription + yyv52 := &x.DesiredStatus yym53 := z.DecBinary() _ = yym53 if false { @@ -56125,21 +56187,21 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { *((*string)(yyv52)) = r.DecodeString() } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.ClientStatus = "" + x.DesiredDescription = "" } else { - yyv54 := &x.ClientStatus + yyv54 := &x.DesiredDescription yym55 := z.DecBinary() _ = yym55 if false { @@ -56147,21 +56209,21 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { *((*string)(yyv54)) = r.DecodeString() } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.ClientDescription = "" + x.ClientStatus = "" } else { - yyv56 := &x.ClientDescription + yyv56 := &x.ClientStatus yym57 := z.DecBinary() _ = yym57 if false { @@ -56169,35 +56231,57 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { *((*string)(yyv56)) = r.DecodeString() } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } z.DecSendContainerState(codecSelfer_containerArrayElem100) if r.TryDecodeAsNil() { - x.TaskStates = nil + x.ClientDescription = "" } else { - yyv58 := &x.TaskStates + yyv58 := &x.ClientDescription yym59 := z.DecBinary() _ = yym59 if false { } else { - h.decMapstringPtrtoTaskState((*map[string]*TaskState)(yyv58), d) + *((*string)(yyv58)) = r.DecodeString() + } + } + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l + } else { + yyb37 = r.CheckBreak() + } + if yyb37 { + z.DecSendContainerState(codecSelfer_containerArrayEnd100) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem100) + if r.TryDecodeAsNil() { + x.TaskStates = nil + } else { + yyv60 := &x.TaskStates + yym61 := z.DecBinary() + _ = yym61 + if false { + } else { + h.decMapstringPtrtoTaskState((*map[string]*TaskState)(yyv60), d) } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -56212,13 +56296,13 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.DeploymentStatus.CodecDecodeSelf(d) } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -56226,21 +56310,21 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.CreateIndex = 0 } else { - yyv61 := &x.CreateIndex - yym62 := z.DecBinary() - _ = yym62 + yyv63 := &x.CreateIndex + yym64 := z.DecBinary() + _ = yym64 if false { } else { - *((*uint64)(yyv61)) = uint64(r.DecodeUint(64)) + *((*uint64)(yyv63)) = uint64(r.DecodeUint(64)) } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -56248,21 +56332,21 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.ModifyIndex = 0 } else { - yyv63 := &x.ModifyIndex - yym64 := z.DecBinary() - _ = yym64 + yyv65 := &x.ModifyIndex + yym66 := z.DecBinary() + _ = yym66 if false { } else { - *((*uint64)(yyv63)) = uint64(r.DecodeUint(64)) + *((*uint64)(yyv65)) = uint64(r.DecodeUint(64)) } } - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { z.DecSendContainerState(codecSelfer_containerArrayEnd100) return } @@ -56270,26 +56354,48 @@ func (x *AllocListStub) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.CreateTime = 0 } else { - yyv65 := &x.CreateTime - yym66 := z.DecBinary() - _ = yym66 + yyv67 := &x.CreateTime + yym68 := z.DecBinary() + _ = yym68 + if false { + } else { + *((*int64)(yyv67)) = int64(r.DecodeInt(64)) + } + } + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l + } else { + yyb37 = r.CheckBreak() + } + if yyb37 { + z.DecSendContainerState(codecSelfer_containerArrayEnd100) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem100) + if r.TryDecodeAsNil() { + x.ModifyTime = 0 + } else { + yyv69 := &x.ModifyTime + yym70 := z.DecBinary() + _ = yym70 if false { } else { - *((*int64)(yyv65)) = int64(r.DecodeInt(64)) + *((*int64)(yyv69)) = int64(r.DecodeInt(64)) } } for { - yyj35++ - if yyhl35 { - yyb35 = yyj35 > l + yyj37++ + if yyhl37 { + yyb37 = yyj37 > l } else { - yyb35 = r.CheckBreak() + yyb37 = r.CheckBreak() } - if yyb35 { + if yyb37 { break } z.DecSendContainerState(codecSelfer_containerArrayElem100) - z.DecStructFieldNotFound(yyj35-1, "") + z.DecStructFieldNotFound(yyj37-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd100) } diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index ad176d13c0c..8b10f289eb4 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -4605,6 +4605,9 @@ type Allocation struct { // CreateTime is the time the allocation has finished scheduling and been // verified by the plan applier. CreateTime int64 + + // ModifyTime is the time the allocation was last updated. + ModifyTime int64 } // Index returns the index of the allocation. If the allocation is from a task @@ -4746,6 +4749,7 @@ func (a *Allocation) Stub() *AllocListStub { CreateIndex: a.CreateIndex, ModifyIndex: a.ModifyIndex, CreateTime: a.CreateTime, + ModifyTime: a.ModifyTime, } } @@ -4767,6 +4771,7 @@ type AllocListStub struct { CreateIndex uint64 ModifyIndex uint64 CreateTime int64 + ModifyTime int64 } // AllocMetric is used to track various metrics while attempting