← Back to Pull requests

feat(cache): support HPA on CacheRuntime via scale subresource and status selector #6223

Open
unknown opened this pull request with 320 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 28, 2026 12:31 UTC
Author

<!--
Please make sure you have read and understood the contributing guidelines;
https://github.com/fluid-cloudnative/fluid/blob/master/CONTRIBUTING.md-->

Ⅰ. Describe what this PR does

Add HPA support for the new CacheRuntime API:

1. Populate Status.Selector: the CacheEngine sets status.selector to the serialized label selector of the worker component (e.g. cacheruntime.fluid.io/component-name=<runtime>-worker,cacheruntime.fluid.io/name=<runtime>), which the scale subresource exposes to HPA for pod discovery.
2. Scale subresource on the CacheRuntime CRD: +kubebuilder:subresource:scale with specReplicasPath: .spec.worker.replicas, statusReplicasPath: .status.worker.currentReplicas, labelSelectorPath: .status.selector — enables kubectl scale and HPA targeting of CacheRuntime, mirroring what the existing runtime CRDs (e.g. AlluxioRuntime) already do.
3. Worker spec sync: replica writes through the scale subresource flow via the existing SyncComponentSpec path to the worker AdvancedStatefulSet.

Note on component optionality: master and worker are optional components (e.g. a P2P cache may have neither). Whether a component is created is decided by the runtime class topology plus the per-component disabled flag, not by the presence of the spec block — so the scale subresource only applies to runtimes with the worker component enabled, and a GET on .../scale failing for a runtime without a worker is expected.

Ⅱ. Does this pull request fix one issue?


#6063

Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.


  • Unit tests for worker selector generation and status population in pkg/ddc/cache/engine.

  • Curvine e2e (test/gha-e2e/curvine/test.sh), deliberately without deploying a real HPA:

  • - asserts status.selector is set and actually discovers the worker pods;
    - reads GET .../scale and asserts spec.replicas, status.replicas and the string selector field (autoscaling/v1 ScaleStatus.Selector, filled by the API server from labelSelectorPath);
    - scales workers up through the scale subresource (the same write path an HPA takes) and down via a direct spec patch, verifying pod counts both ways.

    Ⅳ. Describe how to verify it


    Run the kind-e2e-test workflow (curvine case). The scale subresource contract is verified directly against the API server, so no HPA object is required.

    Ⅴ. Special notes for reviews


    https://github.com/fluid-cloudnative/fluid/pull/6064 is another fix, but has no update for two months.

    Diff: 320 lines (+240 / -80) across 4 files Reviewer: cheyang Review duration: 6425m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 320 lines diff across 4 files
    0.42
    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
    Diff Size diff_size
    0.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #6223"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    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: 41.9% (MEDIUM) · Higher = larger blast radius
    41.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: 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: 22.3% · Safe to merge
    22.3%