Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Introduce the TriggerTimeTracker util in the Endpoints Controller. #73314
Introduce the TriggerTimeTracker util in the Endpoints Controller. #73314
Changes from all commits
9e7f7df
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
How about using read lock here ?
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.
Probably add a piece of comment here to explain why using the minChangedTriggerTime to do the measurement may not yeild the intended result due to multiple update getting merged into one.
Basically, sync1 -> pod1, pod2, pod3 changed -> sync2
minChangedTriggerTime
in this case is time delta between pod3 update and sync2, but the actual time difference may be delta between pod1 update and sync2.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.
You're right, assuming that by pod1, pod2, pod3 you're referring to multiple updates of the same pod.
In such case here we'd see and export the pod3 change time whereas we should've used the pod1 change time.
This was already documented in the TriggerTimeTracker struct documentation, but added it also in the doc of this function.
And just to make one thing clear, we're not operating on time deltas here. Here we only export the "trigger time" which is the time of the oldest change that triggered endpoints object change. Time delta will be computed in kube-proxy to export the actual latency.
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.
nit: can you please split this line?
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.
As discussed offline, it doesn't require splitting. It's below the 100 character limit.
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.
Ignoring service update may result in discrepancy right?
For example:
Service ports got updated and no change on pods. This would result in update in endpoints object. The
minChangedTriggerTime
will still return one of the time delta after the latest pod update, right?In this case, unless we have the something similar to service.LastUpdateTime, I think we can ignore it and skip recording. WDYT?
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 what we do. The minChangedTriggerTime definition is: the min trigger time of all trigger times that have changed since the last sync.
Assuming that only service has changed, the minChangeTriggerTime would be a 'zero' time, as nothing has changed (since we don't have the service.LastUpdateTime and service.CreationTime stays the same). If the ComputeEndpointsLastChangeTriggerTime returns a 'zero' time the result should be ignored and the EndpointsLastChangeTriggerTime shouldn't be exported.
If in future we manage to get the service.LastUpdateTime somehow it will be enough to just change this place and everything will work correctly. That's why I left a TODO here.
I updated the docs and comments to make it easier to understand. Also added a test for that case.