Always set modify time on allocations, and other changes addressing review comments
This commit is contained in:
parent
39d70be009
commit
d340c3adb1
|
@ -820,12 +820,13 @@ func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.Gene
|
|||
return fmt.Errorf("must update at least one allocation")
|
||||
}
|
||||
|
||||
// Add this to the batch
|
||||
n.updatesLock.Lock()
|
||||
// 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...)
|
||||
|
||||
// Start a new batch if none
|
||||
|
|
|
@ -149,9 +149,8 @@ func (s *Server) applyPlan(plan *structs.Plan, result *structs.PlanResult, snap
|
|||
for _, alloc := range req.Alloc {
|
||||
if alloc.CreateTime == 0 {
|
||||
alloc.CreateTime = now
|
||||
} else {
|
||||
alloc.ModifyTime = now
|
||||
}
|
||||
alloc.ModifyTime = now
|
||||
}
|
||||
|
||||
// Dispatch the Raft transaction
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue