-
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 timestamps to evals #5881
add timestamps to evals #5881
Conversation
So the tests on my branch pass (travis-ci/push), but not the ones merged w/ master (travis-ci/pr). I thought it was a transient issue on master, so I'm rerunning and looking into it if its not. UPDATE: yes, it was transient. build is passing now. |
Working on the description, which will include a walkthrough of the method call tracing and where is the correct place to set eval timestamps |
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.
I feel like ModifyTime
should initially be equal to CreateTime
. If subsequentt calls to time.Now()
mean they're not, this (imho) violates the principle of least surprise.
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.
Yay! This will be very helpful.
@@ -235,6 +235,7 @@ func (a *Alloc) Stop(args *structs.AllocStopRequest, reply *structs.AllocStopRes | |||
return fmt.Errorf(structs.ErrUnknownAllocationPrefix) | |||
} | |||
|
|||
now := time.Now().UTC().UnixNano() | |||
eval := &structs.Evaluation{ |
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.
Someday a helper func for making evals might be nice to ensure we always set the time properly:
func NewEval(namespace, type string) *Evaluation {
// get time.now, generate uuid, and set basic fields here
}
Not a blocker for this PR.
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.
Agreed. This was discussed but I opted not to since a big refactor on all eval creations seemed risky and outside of the scope of this PR.
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.
Too bad Go doesn't have constructors! 🐣
// Format the evaluation data | ||
basic := []string{ | ||
fmt.Sprintf("ID|%s", limit(eval.ID, length)), | ||
fmt.Sprintf("Create Time|%s", formattedCreateTime), | ||
fmt.Sprintf("Modify Time|%s", formattedModifyTime), |
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.
Pointing out that for old evals this will print an empty string, which may be ok but odd UX.
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.
Agreed it's not the greatest UX. This behavior is consistent with nomad alloc status
, although it's unlikely at this point that there are old allocs w/o a CreateTime. Going to think about it, will most likely leave as is but add a note in the docs.
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.
Leaving it as is sounds good to me if there's prior art already that does this.
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.
Few more minor comments, otherwise LGTM
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. |
Overview
Added timestamps to evaluations upon creation/modification.
Behavior
Implementation
The key here was to add timestamps to evals in the correct place, which would be where the eval is first registered as part of a raft transaction.
TODO