← Back to Pull requests

Add optional cache for provisioner Secret reads #1611

Open
unknown opened this pull request with 280 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 04, 2026 22:00 UTC
Author

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds --secret-cache-ttl (default 0, disabled) and
--secret-cache-max-entries (default 128).

With many PVCs sharing one StorageClass, every CreateVolume and DeleteVolume
reads the same provisioner Secret with a separate GET, and these reads are
throttled by --kube-api-qps. When enabled, the Secret data is cached for a
fixed time after it was read.

  • expiry is counted from the read and is not extended by use

  • concurrent reads of one Secret share one API call (singleflight)

  • errors, including NotFound, are never cached, and an expired entry is never

  • used instead of an error
  • when the cache is full of unexpired entries, new Secrets are not cached

  • callers get copies of the data

  • used by the Provision path and both DeleteVolume credential paths; deletion

  • still continues without credentials when the Secret cannot be read

    Measured against a local test server with the default client limits (5 QPS,
    burst 10), 100 workers and 1500 reads of one Secret:

    | | API calls | total | median latency |
    |------------|-----------|--------|----------------|
    | before | 1500 | ~5 min | 20s |
    | after, 10s | 1 | 4 ms | 0 |

    Which issue(s) this PR fixes:

    Fixes #1610

    Special notes for your reviewer:

  • Default behaviour is unchanged. NewCSIProvisioner gets two new arguments, so

  • the existing test calls pass 0, 0.
  • golang.org/x/sync moves from an indirect to a direct dependency; it was

  • already vendored.
  • Trade-offs: a rotated or deleted Secret is noticed only after the TTL, and

  • credentials stay in memory for up to the TTL. A failed CSI call does not clear
    the entry, so recovery after a rotation waits for the TTL (the provisioner
    retries with backoff). Not caching new Secrets when the cache is full is
    intentional; an LRU is possible if you prefer it.
  • external-attacher has the same direct read; I did not change it here.
  • Does this PR introduce a user-facing change?:

    ``release-note
    Add the
    --secret-cache-ttl and --secret-cache-max-entries flags to cache the Secrets used as provisioner credentials. The cache is disabled by default.
    ``

    Diff: 280 lines (+210 / -70) across 3 files Reviewer: jsafrane Review duration: 13612m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.63) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.63 · 280 lines diff across 3 files
    0.63
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.337
    Sensitive Paths sensitive_paths
    0.063
    Real PR Conversation Timeline
    1 comments
    "Review active on #1611"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 62.8% (MEDIUM) · Higher = larger blast radius
    62.8%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 33.5% · Safe to merge
    33.5%