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
track latency incurred in various layers of apiserver #107910
Conversation
d5cd2b2
to
740bb81
Compare
/assign @deads2k @wojtek-t @dgrisonnet |
@wojtek-t Is it possible to decorate from the watch cache layer and down? |
bc6611c
to
7eb7f54
Compare
/triage accepted |
/retest |
// NewETCDLatencyTracker returns an implementation of | ||
// clientv3.KV that times the calls from the specified | ||
// 'delegate' KV instance in order to track latency incurred. | ||
func NewETCDLatencyTracker(delegate clientv3.KV) clientv3.KV { |
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.
instead of tapping into storage.Interface
, I am now tapping into etcd3 client KV
so we can measure latency from etcd3 round trips only
2db240a
to
9a12077
Compare
} | ||
|
||
type clientV3TxnTracker struct { | ||
ctx context.Context |
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.
blech. Exists in the etcd client though, so I think we're stuck.
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, tkashem 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 |
a timeout in some other layer, may be in collection of artifatcs? /test pull-kubernetes-integration |
I think this PR is doing something to the etcd client that is making it fail /hold |
now it went through, let me give it another shot to see if that was unrelated to this PR, I will unhold Sorry for holding it but this job is very sensible to things that impact apiserver resource usage, I just wanted to be completely sure 😄 /test pull-kubernetes-integration |
|
||
annotations := map[string]string{} | ||
if latency := tracker.TransformTracker.GetLatency(); latency != 0 { | ||
annotations["apiserver.latency.k8s.io/transform-response-object"] = latency.String() |
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.
sorry for the late nit: can we use consts for these strings and use those when we retrieve values? I see spots in the PR where we assume that the key is there if the annotations map is returned but a small bug in the key could cause a NPE.
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.
@logicalhan we don't retrieve by key name where the annotations are returned. it added "apiserver.latency.k8s.io/total" key to the annotations map if it wan non-empty, but I changed it a bit so that the annotations map returned is not mutated (that seems a better pattern)
With this i don't see any need to use const since these key names are are not referred to anywhere else.
// record the total latency for this request, for convenience.
- layerLatencies["apiserver.latency.k8s.io/total"] = latency.String()
+ audit.LogAnnotation(ev, "apiserver.latency.k8s.io/total", latency.String())
for k, v := range layerLatencies {
audit.LogAnnotation(ev, k, v)
}
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.
but if you think having these key names in one place is more readable, I can make this change :)
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.
nah it's fine then, thanks!
/lgtm
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.
@logicalhan the keys have been moved to consts now, ptal
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.
Thanks!!
@tkashem but you have a new comment #107910 (comment) you are free to unhold, the job has started to be unstable since a few hours , so is not because of this PR |
9a12077
to
7583bfa
Compare
i did a force push, this is the only change.
|
/hold cancel |
7583bfa
to
1d1a44c
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
What type of PR is this?
/kind feature
What this PR does / why we need it:
http.ResponseWriter.Write
and admission webhooksWhich issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: