Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

simonpasquier
Copy link
Contributor

@simonpasquier simonpasquier commented Apr 18, 2024

Description

controller-runtime also calls metrics.Register() during init and this function can be called only once. To ensure that the k8s client metrics get updated, the global variables need to be set again by the operator.

https://github.com/kubernetes-sigs/controller-runtime/blob/67b27f27e514bd9ac4cf9a2d84dec089ece95bf7/pkg/metrics/client_go_adapter.go#L42-L55 https://github.com/kubernetes/client-go/blob/aa7909e7d7c0661792ba21b9e882f3cd6ad0ce53/tools/metrics/metrics.go#L129-L170

Closes #6513

Type of change

What type of changes does your code introduce to the Prometheus operator? Put an x in the box that apply.

  • CHANGE (fix or feature that would cause existing functionality to not work as expected)
  • FEATURE (non-breaking change which adds functionality)
  • BUGFIX (non-breaking change which fixes an issue)
  • ENHANCEMENT (non-breaking change which improves existing functionality)
  • NONE (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)

Verification

Please check the Prometheus-Operator testing guidelines for recommendations about automated tests.

Changelog entry

Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.

fix missing `prometheus_operator_kubernetes_client_http_requests_total` metric.

controller-runtime also calls `metrics.Register()` during init and this
function can be called only once. To ensure that the k8s client metrics
get updated, the global variables need to be set again by the operator.

https://github.com/kubernetes-sigs/controller-runtime/blob/67b27f27e514bd9ac4cf9a2d84dec089ece95bf7/pkg/metrics/client_go_adapter.go#L42-L55
https://github.com/kubernetes/client-go/blob/aa7909e7d7c0661792ba21b9e882f3cd6ad0ce53/tools/metrics/metrics.go#L129-L170

Signed-off-by: Simon Pasquier <[email protected]>
@simonpasquier simonpasquier requested a review from a team as a code owner April 18, 2024 08:26
@simonpasquier
Copy link
Contributor Author

I've tested locally and it seems to work. To avoid future regressions, I'll file an issue to add e2e tests on prometheus-operator metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants