Skip to content

Refactor metric defer() statements to gRPC metric interceptor #1876

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

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

pwschuurman
Copy link
Contributor

@pwschuurman pwschuurman commented Nov 26, 2024

Migrate metric defer() statements to gRPC metric interceptor. This allows for more accurate error code reporting of the internal operation_errors metric when gRPC handling functionality is refactored

/kind api-change
/kind bug

/kind cleanup

/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it: Currently the ControllerServer reports error metrics through a defer() function pattern. This captures the output of captured variables when the function returns. If captured references are not updated (eg: a statement is refactored, and the err variable is not updated), the error code reported may not be accurate. This can result in poor error classification when this metric is used for reporting (as all error codes may be classified as INTERNAL).

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Improved field accuracy for `csidriver/operation_errors` metric.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Nov 26, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 26, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pwschuurman

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 26, 2024
@pwschuurman
Copy link
Contributor Author

/retest

1 similar comment
@pwschuurman
Copy link
Contributor Author

/retest

@pwschuurman
Copy link
Contributor Author

/assign @amacaskill

@amacaskill
Copy link
Member

@pwschuurman Can you please add a release note?

The release note in the PR is how changes show up in the release notes/changelog that is generated when you press the generate release notes button when cutting a release. I think this is useful to know what version had what change, especially for SLO changes when we are debugging to see if whatever cluster triggered the alert, has your fix.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Dec 5, 2024
@pwschuurman
Copy link
Contributor Author

/hold Tests added but want to add a regression test for one of the rpc calls that invoke the GetMetadataFromDisk()

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 6, 2024
…lows for more accurate error code reporting if gRPC functionality is refactored
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 6, 2024
@pwschuurman
Copy link
Contributor Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 6, 2024
@amacaskill
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 6, 2024
@k8s-ci-robot k8s-ci-robot merged commit a06d250 into kubernetes-sigs:master Dec 6, 2024
7 checks passed
@pwschuurman
Copy link
Contributor Author

/cherry-pick release-1.14

@k8s-infra-cherrypick-robot

@pwschuurman: #1876 failed to apply on top of branch "release-1.14":

Applying: Migrate metric defer() statements to gRPC metric interceptor. This allows for more accurate error code reporting if gRPC functionality is refactored
Using index info to reconstruct a base tree...
M	cmd/gce-pd-csi-driver/main.go
M	pkg/gce-pd-csi-driver/controller.go
M	pkg/gce-pd-csi-driver/gce-pd-driver.go
M	pkg/gce-pd-csi-driver/gce-pd-driver_test.go
M	test/sanity/sanity_test.go
Falling back to patching base and 3-way merge...
Auto-merging test/sanity/sanity_test.go
Auto-merging pkg/gce-pd-csi-driver/gce-pd-driver_test.go
CONFLICT (content): Merge conflict in pkg/gce-pd-csi-driver/gce-pd-driver_test.go
Auto-merging pkg/gce-pd-csi-driver/gce-pd-driver.go
Auto-merging pkg/gce-pd-csi-driver/controller.go
CONFLICT (content): Merge conflict in pkg/gce-pd-csi-driver/controller.go
Auto-merging cmd/gce-pd-csi-driver/main.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Migrate metric defer() statements to gRPC metric interceptor. This allows for more accurate error code reporting if gRPC functionality is refactored

In response to this:

/cherry-pick release-1.14

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.

@pwschuurman
Copy link
Contributor Author

/cherry-pick release-1.15

@k8s-infra-cherrypick-robot

@pwschuurman: new pull request created: #1886

In response to this:

/cherry-pick release-1.15

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.

Fricounet added a commit to DataDog/gcp-compute-persistent-disk-csi-driver that referenced this pull request Dec 18, 2024
This fixes a regression introduced in kubernetes-sigs#1876 where the driver would start
panicking on startup if `--http-endpoint` was specified. This was caused
by the metrics not being initialized anymore during startup. The
proposed fix involves using the `Reset` methods of the metrics object
instead of trying to redefine them each time they need to be reset.
Fricounet added a commit to DataDog/gcp-compute-persistent-disk-csi-driver that referenced this pull request Dec 18, 2024
This fixes a regression introduced in kubernetes-sigs#1876 where the driver would start
panicking on startup if `--http-endpoint` was specified. This was caused
by the metrics not being initialized anymore during startup. The
proposed fix involves using the `Reset` methods of the metrics object
instead of trying to redefine them each time they need to be reset.
k8s-infra-cherrypick-robot pushed a commit to k8s-infra-cherrypick-robot/gcp-compute-persistent-disk-csi-driver that referenced this pull request Jan 2, 2025
This fixes a regression introduced in kubernetes-sigs#1876 where the driver would start
panicking on startup if `--http-endpoint` was specified. This was caused
by the metrics not being initialized anymore during startup. The
proposed fix involves using the `Reset` methods of the metrics object
instead of trying to redefine them each time they need to be reset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants