← Back to Pull requests

feat: Export kubernetes client-go metrics #1578

Open
AndrewSirenko opened this pull request with 430 lines diff across 4 files
View on GitHub
AndrewSirenko AndrewSirenko commented on Sep 11, 2026 01:33 UTC
Author

What type of PR is this?

/kind feature

What this PR does / why we need it:

We've had some EKS customers throttled by our default kube-qps and kube-burst sidecar args. We realized sidecars weren't exporting the metrics that would help us see the impact of this throttle like rest_client_rate_limiter_duration_seconds.

PR follows https://github.com/kubernetes-csi/external-provisioner/pull/579 to add a blank import of k8s.io/component-base/metrics/prometheus/restclient so this sidecar registers and serves the client-go metrics in default legacy Prometheus registry.

Testing (AI proof, logs here): https://gist.github.com/AndrewSirenko/512be4fc29e90e4237384f337da62713

  • Built the sidecar image from this branch and deployed it alongside the AWS EBS CSI Driver (via Helm, controller.enableMetrics=true) on an EKS cluster.

  • Scraped the sidecar's /metrics endpoint and confirmed the full rest_client_ family is now emitted (rest_client_requests_total, rest_client_request_duration_seconds, rest_client_rate_limiter_duration_seconds, etc.)

  • Negative control: deployed the stock upstream sidecar image with the identical chart/metrics config — rest_client_ was absent (0 series) while workqueue_ was still present.
  • Which issue(s) this PR fixes:

    Fixes # N/A

    Special notes for your reviewer:

    One-line change in same vein as existing _ "k8s.io/component-base/metrics/prometheus/clientgo/leaderelection" blank imports already present in this file. + Updated vendor deps.

    Does this PR introduce a user-facing change?:

    ``release-note
    Serve client-go REST client metrics (rest_client_
    )
    ``

    Diff: 430 lines (+401 / -29) across 4 files Reviewer: jsafrane Review duration: 40138m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.67) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.67 · 430 lines diff across 4 files
    0.67
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.90 · 4 substantive comment(s)
    0.90
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    87%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.363
    Sensitive Paths sensitive_paths
    0.067
    Real PR Conversation Timeline
    5 items
    kubernetes-prow[bot] kubernetes-prow[bot] commented on Sep 11, 2026 01:33 UTC
    Bot

    [APPROVALNOTIFIER] This PR is NOT APPROVED

    This pull-request has been approved by: <a href="https://github.com/kubernetes-csi/external-provisioner/pull/1578#" title="Author self-approved">AndrewSirenko</a>
    Once this PR has been reviewed and has the lgtm label, please assign xing-yang for approval. For more information see the Code Review Process.

    The full list of commands accepted by this bot can be found here.

    <details open>
    Needs approval from an approver in each of these files:

  • OWNERS
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":["xing-yang"]} -->

    jsafrane jsafrane commented on code on Sep 11, 2026 09:08 UTC
    Code Review
    cmd/csi-provisioner/csi-provisioner.go:1
    @@ -56,6 +56,7 @@ import (
     	_ "k8s.io/component-base/logs/json/register"
     	"k8s.io/component-base/metrics/legacyregistry"
     	_ "k8s.io/component-base/metrics/prometheus/clientgo/leaderelection" // register leader election in the default legacy registry
    +	_ "k8s.io/component-base/metrics/prometheus/restclient"              // register client-go REST client metrics (incl. rate limiter latency)

    This needs to be done in all sidecars and it's hard to keep them consistent. Would it make sense to move it to csi-lib-utils and plug it into e.g. github.com/kubernetes-csi/csi-lib-utils/metrics? Do all sidecars import it? Is there anyone who would not want client-go metrics?

    (And you could move all other dummy imports there too...)

    AndrewSirenko AndrewSirenko commented on code on Sep 17, 2026 02:08 UTC
    Code Review
    cmd/csi-provisioner/csi-provisioner.go:1
    @@ -56,6 +56,7 @@ import (
     	_ "k8s.io/component-base/logs/json/register"
     	"k8s.io/component-base/metrics/legacyregistry"
     	_ "k8s.io/component-base/metrics/prometheus/clientgo/leaderelection" // register leader election in the default legacy registry
    +	_ "k8s.io/component-base/metrics/prometheus/restclient"              // register client-go REST client metrics (incl. rate limiter latency)

    Works for me!

    I'll prep PRs for:
    1. csi-lib-utils change
    2. csi-lib-utils release
    3. sidecar refactorings

    Thanks!

    AndrewSirenko AndrewSirenko commented on code on Sep 18, 2026 21:42 UTC
    Code Review
    cmd/csi-provisioner/csi-provisioner.go:1
    @@ -56,6 +56,7 @@ import (
     	_ "k8s.io/component-base/logs/json/register"
     	"k8s.io/component-base/metrics/legacyregistry"
     	_ "k8s.io/component-base/metrics/prometheus/clientgo/leaderelection" // register leader election in the default legacy registry
    +	_ "k8s.io/component-base/metrics/prometheus/restclient"              // register client-go REST client metrics (incl. rate limiter latency)

    Done! Will refactor after https://github.com/kubernetes-csi/csi-lib-utils/pull/219 is merged.

    lmk if you want me to help make csi-lib-utils release but we can also wait until closer to k8s 1.38 🤷

    Reviewers
    Assignees
    AndrewSirenko AndrewSirenko
    Labels
    risk: low confidence: 87.2% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 66.9% (HIGH) · Higher = larger blast radius
    66.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 87.2% · Lower = rushed or shallow review
    87.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.6% · Safe to merge
    8.6%