-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ModifyTime to Allocation and update it both on plan applies and c… #3446
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is testing anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had added this test to debug serialization (before I realized there was generated code that needed to be updated). Left it here because it helps catch the problem if you update the struct but not the serializer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although, now that I think about this uses msgpack codec and not the generated codec so I don't know where I was going with that. Seems like this test is still useful as it verifies that the modtime persisted correctly in the state store. |
||
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) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should always be updated (remove the else and always run). The reason I say this is that when the scheduler first creates the allocation we want |
||
alloc.ModifyTime = now | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,6 +226,10 @@ func TestPlanApply_applyPlan(t *testing.T) { | |
t.Fatalf("missing job") | ||
} | ||
|
||
if out.ModifyTime <= 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you test that when it is created it gets a modify time too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
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 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment on what this code is doing