-
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
api: add StartedAt
in Node.DrainStrategy
#6698
Conversation
3b7d756
to
1024103
Compare
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.
Would it be preferable to setup a var of time.Time
outside the two if statements and then assign this within the first if statement as needed to also be used in the second? This would mean the started time and deadline are consistent with the user passed DrainStrategy.Deadline
.
nomad/node_endpoint.go
Outdated
// Mark the deadline time | ||
if args.DrainStrategy != nil && args.DrainStrategy.Deadline.Nanoseconds() > 0 { | ||
args.DrainStrategy.ForceDeadline = time.Now().Add(args.DrainStrategy.Deadline) | ||
args.DrainStrategy.ForceDeadline = time.Now().Add(args.DrainStrategy.Deadline).UTC() |
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 like @jrasell's idea of having a var startedAt time that we could then use here as well to add on to. There seems to be at least one more location calling time.Now that could also benefit from using a shared variable
Ah! That makes perfect sense, thanks for the feedback @jrasell @drewbailey |
@jrasell @drewbailey I refactored the logic to use a single value for current time. Let me know if it's better. I also remove the check for |
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.
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. |
The new
StartedAt
field records the time the current drain process started in a node.Sample response:
Fixes #6694