-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 LastModifyTime to catalog entities #4744
Conversation
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.
That's quite nice, however, I'll also add a lastStateChange specifically for heathcheck that would be modified Only when state do change, ie: none to passing, passing to critical or warning... The idea is to be able to build progressive load balancing based on this value, for instance for increasing up weight smoothly.
With LastModified, changing notes or output on a healthcheck would change the LastModified, but we would like to have clear semantics here
@pierresouchay Done :) |
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.
@Aestek looks good to me. Are we sure the clock is UTC and monotonic as well?
@pierresouchay |
@Aestek absolutely, all should be UTC only and monotonic if possible, so increasing index should increase (or equal) the timestamp. Second granularity should be enough, but OK for Ms |
@pierresouchay
There's a few things to note :
|
The second point issue could actually be worse if you had one server going far in the future because of a (really) bogus situation, actually preventing all remaining "healthy" servers even to update the entries for undefined time |
Let's get the monotonic change of clock for a given server leader. Of course addressing clock drift between servers is out of scope, but time adjustments is not (hence the monotonic and 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.
First, I like the idea of keeping mtimes for entries. However, before giving this a more thorough review there is one big problem I see.
In order to keep the state consistent across all servers the last modification time needs to be set BEFORE the modification gets raftApply'ed in the agent/consul/catalog_endpoint.go code. Otherwise each server is going to have a slightly different lastModifyTime (hopefully not more than a few millisecond difference but still a difference).
So you should timestamp it within the RPC code. This also means that the fsm and state store do not need any timestamping capabilities so much of the modifications made to that code wont be needed.
@mkeeler Indeed, I totally agree with you. Modifying the RPC code for this seems like too much change for this feature. Proposal :The most important thing for us in these changes is the |
30b75a7
to
d68d003
Compare
@mkeeler I've updated the PR based on my last message. |
@pierresouchay I've also changed to use UTC + monotonic increase. One thing to note is that if a check is serialized are loaded back in (from an agent restart for example) the monotonic clock will be lost and the implementation will fallback to wall clock. |
d68d003
to
f11e3f4
Compare
@Aestek If I understand your proposal you are saying that the LastStatusModifyTime would be set on the agent and then the AE sync would push that up to the servers. I will have to think on that a little more and get back with you. This should work for agent managed services but external services managed via the API would have to find another way to coordinate on the mtime. |
@mkeeler Yep, exactly. It seems to me that we can treat API managed just like agent managed checks: as soon a check status is updated, LastStatusModifyTime would be updated in the same fashion. Do you propose that a new new field should be added to |
f11e3f4
to
c08a21e
Compare
2b148f3
to
58b8889
Compare
This field is updated when the check status changes and allows to adjust behaviour based on how much time has passed since the check is "passing" for example.
58b8889
to
e90e8c9
Compare
@Aestek are you still interested in adding this? I went through all the previous conversation and I like the latest version of your PR, because it has a small scope and fixes your issue. I was wondering if it is necessary to provide an integration for services that are managed externally (eg by consul-esm). It seems to me that would be something we could do later if there is demand for it. /cc @eikenb |
@i0rek yes, we are still interested in this. as you pointed out external services will need to be managed manually but at least "standard" services will have this information. |
@ShimmerGlass do you have time to rebase your PR? |
Hello all - This has been in limbo for a while now. I am going to close due to inactivity and the code base progressing from here. @ShimmerGlass , or whomever would like to continue this - feel free to rebase, open a new PR, and we will review it. |
Implementation for #3973
This change adds a new field
LastModifyTime
toNodeService
,ServiceNode
,Node
, andHealthCheck
structs. This field is initialized to the current time upon registration on the server side, and is then kept up to date when a mofification is made (aka when !old.IsSame(new)).