Skip to content
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

Merged
merged 2 commits into from
Oct 26, 2017

Conversation

preetapan
Copy link
Member

…lient initiated updates

@@ -776,6 +776,10 @@ func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.Gene

// Add this to the batch
n.updatesLock.Lock()
now := time.Now().UTC().UnixNano()
Copy link
Contributor

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

@@ -1445,6 +1447,10 @@ func TestClientEndpoint_GetAllocs_Blocking(t *testing.T) {
t.Fatalf("bad: %#v", resp2.Allocs)
}

if resp2.Allocs[0].ModifyTime != now {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is testing anything?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The 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 CreateTime == ModifyTime

@@ -226,6 +226,10 @@ func TestPlanApply_applyPlan(t *testing.T) {
t.Fatalf("missing job")
}

if out.ModifyTime <= 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@preetapan preetapan merged commit 95d26c7 into b-nomad-0.7.1 Oct 26, 2017
@preetapan preetapan deleted the f-modify-time-alloc branch January 25, 2018 19:02
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants