-
Notifications
You must be signed in to change notification settings - Fork 303
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 metrics to track endpointslice staleness #1930
Add metrics to track endpointslice staleness #1930
Conversation
Hi @sawsa307. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
67915aa
to
187446e
Compare
/assign @swetharepakula |
/ok-to-test |
pkg/neg/syncers/transaction.go
Outdated
s.logger.V(3).Info("Endpoint slice syncs", "Namespace/Name", key, "staleness", staleness) | ||
|
||
// remove from previous map since this eps is updated | ||
delete(s.epsLastSyncTimestampMap, key) |
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.
For this metric, I don't think we need to track the lastSyncTimestamp per EPS. we have the following cases:
- EPS newly created since last syncer sync
- EPS existed previously and was processed during the lastSyncer Sync
Since we already know when we last synced the syncer (from the svcNeg CR), you just need to check if the EPS creation timestamp is before or after the lastSyncTimestamp. If the creationTS is after now() then you publish now()-creationTS() for that endpoint's staleness. If creationTS is before now() then you publish now()-syncerLastSync timestamp.
Otherwise you have to add logic that will allow you to recognize when an EPS was deleted as you will never delete those from the map.
91de2da
to
b34fe9e
Compare
pkg/neg/syncers/transaction.go
Outdated
negCR, err := getNegFromStore(s.svcNegLister, s.Namespace, s.NegSyncerKey.NegName) | ||
if err != nil { | ||
s.logger.Error(err, "unable to retrieve neg from the store", "neg", klog.KRef(s.Namespace, s.NegName)) | ||
return err |
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.
since this is only for metrics, do not return an error.
pkg/neg/syncers/transaction.go
Outdated
if lastSyncTimestamp.Before(&epsCreationTimestamp) { | ||
epsStaleness = time.Since(epsCreationTimestamp.Time) | ||
} else { | ||
epsStaleness = time.Since(lastSyncTimestamp.Time) | ||
} |
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.
We can remove the else and you don't need line 257 either.
epsStaleness := time.Since(lastSyncTimestamp.Time)
if lastSyncTimestamp.Before(&epsCreationTimestamp) {
epsStaleness = time.Since(epsCreationTimestamp.Time)
}
b34fe9e
to
0824e66
Compare
0824e66
to
7e37954
Compare
pkg/neg/syncers/transaction.go
Outdated
endpointslice := slice.(*discovery.EndpointSlice) | ||
endpointSlices[i] = endpointslice | ||
|
||
negCR, err := getNegFromStore(s.svcNegLister, s.Namespace, s.NegSyncerKey.NegName) |
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.
move this outside of the for loop. There is only one NEG per syncer.
pkg/neg/syncers/transaction.go
Outdated
if err != nil { | ||
s.logger.Error(err, "unable to retrieve neg from the store", "neg", klog.KRef(s.Namespace, s.NegName)) | ||
} else { | ||
var epsStaleness time.Duration |
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.
remove this. Initialize when you will use it
7e37954
to
3240b9f
Compare
Added metrics to track the sync staleness of endpointslices, where staleness is defined as how long since it has been last processed.
3240b9f
to
8669f63
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sawsa307, swetharepakula The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Added metrics to track the sync staleness of endpointslices, where staleness is defined as how long since it has been last processed.