-
Notifications
You must be signed in to change notification settings - Fork 238
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
feat: add volume attachment time & csi grpc execution time metrics #1142
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: iltyty The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @iltyty. Thanks for your PR. I'm waiting for a kubernetes-sigs 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-sigs/prow repository. |
/ok-to-test |
fcc7310
to
438034b
Compare
249b43d
to
027da89
Compare
pkg/common/interceptors.go
Outdated
return fullName[i+1:] | ||
} | ||
|
||
func observeExecTime(time int64, method, driverType, volumeId string, err error) { |
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.
func observeExecTime(time int64, method, driverType, volumeId string, err error) { | |
func observeExecTime(time time.Duration, method, driverType, volumeId string, err error) { |
Just pass in the Duration to avoid any ambiguous about unit.
pkg/common/interceptors.go
Outdated
case ControllerPublish, ControllerUnpublish, NodeStage, NodeUnstage, NodeUnpublish: | ||
start := time.Now() | ||
resp, err := handler(ctx, req) | ||
execTime := time.Since(start).Milliseconds() |
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.
execTime := time.Since(start).Milliseconds() | |
execTime := time.Since(start).Seconds() |
Use seconds as it already returns a float64.
func NewCsiGrpcExecTimeCollector() (Collector, error) { | ||
return &CsiGrpcExecTimeCollector, nil | ||
} |
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.
This is confusing. It is named New but returns an existing object.
pkg/metric/volume_stat_collector.go
Outdated
const ( | ||
VolumeStatsCollectorName = "volume_stats" | ||
VolumeStatsLabelType = "type" | ||
VolumeStatsLabelId = "id" |
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 ID as we discussed. We don't expect unbounded number of label values.
pkg/common/interceptors.go
Outdated
if !strings.Contains(fullName, "/") || i == len(fullName)-1 { | ||
return "" | ||
} | ||
return fullName[i+1:] |
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 think this is not needed? If "/" is not in fullName, LastIndex will return -1, and fullName[i+1:] should become the fullName.
If i == len(fullName)-1, fullName[i+1:] will become empty string automatically.
pkg/common/interceptors.go
Outdated
return codes.Unknown | ||
} | ||
|
||
func observeVolumeAttachmentTime(curTime int64, req *csi.NodePublishVolumeRequest, driverType string, err error) { |
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.
func observeVolumeAttachmentTime(curTime int64, req *csi.NodePublishVolumeRequest, driverType string, err error) { | |
func observeVolumeAttachmentTime(curTime time.Time, req *csi.NodePublishVolumeRequest, driverType string, err error) { |
Again, to avoid ambiguity.
pkg/common/interceptors.go
Outdated
|
||
func observeVolumeAttachmentTime(curTime int64, req *csi.NodePublishVolumeRequest, driverType string, err error) { | ||
if client == nil { | ||
if client = getK8sClient(); client == nil { |
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.
This is not thread safe. And please try to avoid global variable.
pkg/common/interceptors.go
Outdated
log.Warnf("observeVolumeAttachmentTime: empty pod name/namespace: %s, %s", podName, podNamespace) | ||
return | ||
} | ||
pod, err := client.CoreV1().Pods(podNamespace).Get(context.Background(), podName, metav1.GetOptions{}) |
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.
Additional API server invocation. This can hinder the overall throughput of CSI. We should try to avoid this. Combine it to the runtime class detection?
execTime := time.Since(start).Milliseconds() | ||
observeExecTime(execTime, method, driverType, volumeId, err) | ||
return resp, err | ||
case NodePublish: |
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 add this one to a real NodePublishVolume handler? We should avoid string comparisons and prefer strongly typed handler generally.
e7fb58d
to
4734f6d
Compare
What type of PR is this?
/kind feature
What this PR does / why we need it:
Which 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.: