← Back to Pull requests

perf(cache): derive worker node affinity during status construction to avoid duplicate read #6200

Open
unknown opened this pull request with 245 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 04, 2026 11:12 UTC
Author

Ⅰ. Describe what this PR does


Previously, each CacheRuntime status update cycle read the worker AdvancedStatefulSet twice:
1. In manager.ConstructComponentStatus(...) to build worker replica status.
2. Immediately after in manager.GetNodeAffinity(...) to compute worker node affinity.

This PR extends ComponentManager with ConstructComponentStatusAndAffinity(...) so that worker node affinity is derived directly from the single workload read that status construction already performs.

This addresses #5879 by cutting the lookup count in half (from 2 down to 1 Get per status cycle) with:

  • Zero staleness: Any out-of-band updates to the worker StatefulSet's nodeSelector are immediately reflected in status.CacheAffinity on the very next reconcile cycle (self-healing, without stale affinity reaching the nodeaffinitywithcache webhook).

  • No engine-level caching: Eliminates cache invalidation complexity, copy-discipline hazards, or pointer-identity issues.
  • Ⅱ. Does this pull request fix one issue?


    fixes #5879

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


  • pkg/ddc/cache/component/component_test.go:

  • - Added test verifying ConstructComponentStatusAndAffinity returns both status and affinity for AdvancedStatefulSetManager.
    - Added test verifying ConstructComponentStatusAndAffinity returns both status and affinity for DaemonSetManager.
  • pkg/ddc/cache/engine/status_test.go:

  • - Added test verifying worker workload is read exactly once per status cycle (1 Get per cycle).
    - Added test pinning zero staleness: out-of-band updates to the worker StatefulSet's nodeSelector immediately update status.CacheAffinity on the subsequent cycle.
    - Added test verifying error propagation when the worker component is not found.

    Ⅳ. Describe how to verify it


    go test -v ./pkg/ddc/cache/...
    

    Ⅴ. Special notes for reviews


    None

    Diff: 245 lines (+183 / -62) across 3 files Reviewer: cheyang Review duration: 5819m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 245 lines diff across 3 files
    0.39
    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.329
    Real PR Conversation Timeline
    1 comments
    "Review active on #6200"
    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: 38.9% (MEDIUM) · Higher = larger blast radius
    38.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: 20.7% · Safe to merge
    20.7%