Skip to content
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

[metrics] Fix panic during metrics manager startup #1895

Merged

Conversation

Fricounet
Copy link
Contributor

What type of PR is this?
/kind bug

What this PR does / why we need it:

This fixes a regression introduced in #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.

Which issue(s) this PR fixes:

Fixes #1894

Tested the PR by building an image and making sure it did not panic:

$ docker buildx build --platform "linux/amd64" --tag gcp-pd-csi-driver:test --build-arg=BUILDPLATFORM=linux --build-arg=STAGINGVERSION=v1.15.3 -f Dockerfile --load .
...
$ docker run -it gcp-pd-csi-driver:test --http-endpoint=localhost:8080
I1218 13:22:38.273351       1 main.go:114] Operating compute environment set to: production and computeEndpoint is set to: <nil>
I1218 13:22:38.274410       1 main.go:123] Sys info: NumCPU: 20 MAXPROC: 1
W1218 13:22:38.274885       1 metrics.go:143] "GKE_PDCSI_VERSION" env not set
I1218 13:22:38.280217       1 metrics.go:133] Metric server listening at "localhost:8080"
W1218 13:22:38.286433       1 gce.go:203] GOOGLE_APPLICATION_CREDENTIALS env var not set
F1218 13:22:38.286477       1 main.go:221] Failed to get cloud provider: google: could not find default credentials. See https://cloud.google.com/docs/authentication/external/set-up-adc for more information

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fixed panic issue during startup when using the --http-endpoint flag

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-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 18, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @Fricounet. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 18, 2024
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 18, 2024
@msau42
Copy link
Contributor

msau42 commented Dec 28, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 28, 2024
@pwschuurman
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 2, 2025
@pwschuurman
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Fricounet, 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 2, 2025
@k8s-ci-robot k8s-ci-robot merged commit c29a4ee into kubernetes-sigs:master Jan 2, 2025
7 checks passed
@leiyiz
Copy link
Contributor

leiyiz commented Jan 2, 2025

/cherry-pick release-1.15

@k8s-infra-cherrypick-robot

@leiyiz: new pull request created: #1898

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.

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/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic on driver startup when using --http-endpoint in v1.15.3
6 participants