← Back to Pull requests

fix(cache): emit warning event on tieredStore drift and document update limitations #6219

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 22, 2026 08:54 UTC
Author

Ⅰ. Describe what this PR does

When spec.worker.tieredStore is updated on an existing CacheRuntime, the runtime configuration ConfigMap (fluid-runtime-config-<name>) is recomputed from spec on every sync (cm.go:102), but the worker pod volumes (emptyDir.sizeLimit, emptyDir storage medium, memory tmpfs /dev/shm) cannot be updated in-place by SyncComponentSpec without pod recreation.

This caused an undetected split between the ConfigMap and the worker pod volumes:

  • The ConfigMap carries the updated quotas and medium settings.

  • The worker pod volumes retain their initial creation-time sizes and media.

  • When worker pods restart for any reason (eviction, rolling update, node reboot), the cache process reads the updated ConfigMap quota and attempts to allocate more space than the container tmpfs or emptyDir volume permits, resulting in crashes or truncated writes with no warning or event emitted.
  • This PR addresses the issue by:
    1. Adding worker tieredStore drift detection (checkWorkerTieredStoreDrift) in syncRuntimeSpec (pkg/ddc/cache/engine/sync.go):
    - Compares level-by-level quotas in runtime.Spec.Worker.TieredStore.Levels against the actual sizeLimit of worker pod volumes (Quantity.Cmp).
    - Compares emptyDir storage media (Medium) to detect disk $\leftrightarrow$ Memory flips.
    - Checks both processMemory and emptyDir volumes by their deterministic names (getMemoryTieredStoreVolumeName, getTieredStoreVolumeName).
    - Verifies declared hostPath paths match the pod's volume configurations.
    - Detects removed or orphaned tieredStore volumes on the worker pod.
    - Modularized into low-complexity helpers (checkProcessMemoryDrift, checkEmptyDirDrift, checkHostPathDrift).
    2. Emits a RuntimeTieredStoreConflict Warning event on the CacheRuntime object when drift is detected.
    - Remediation guidance directs users: "Delete and recreate the CacheRuntime to apply changes."
    - Throttles the Warning event to a 10-minute interval (e.getTieredStoreWarningInterval()) to prevent event spam while ensuring the event remains visible within the default 1-hour Kubernetes event TTL.
    - Automatically resets the cooldown when the split is resolved.
    3. Ensures worker PodSpec is read during sync even when neither CacheRuntime nor CacheRuntimeClass declares resources (closing the gap where podSpec was only read inside if workerResources != nil).
    4. Adds end-to-end controller loop verification in test/gha-e2e/curvine/test.sh (verify_tieredstore_drift_warning) asserting that a real controller detects tieredStore drift on patch, emits RuntimeTieredStoreConflict, and resets upon reversal.
    5. Documents that spec.worker.tieredStore cannot be updated in-place and details the drift warning behavior in both English and Chinese documentation (cacheruntime_spec_update.md and cache_runtime_tieredstore.md).

    Ⅱ. Does this pull request fix one issue?

    fixes #6192

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

    Added unit test suite in pkg/ddc/cache/engine/sync_test.go (Context("tiered store drift detection and warning")):

  • should not emit a warning event when tiered store matches worker pod volumes: verifies 0 warning events when volumes match spec (both processMemory and emptyDir).

  • should emit a Warning event when processMemory quota in spec drifts from worker volume sizeLimit: verifies RuntimeTieredStoreConflict event and error description for processMemory quota drift.

  • should emit a Warning event when emptyDir quota in spec drifts from worker volume sizeLimit: verifies Warning event for emptyDir quota drift.

  • should emit a Warning event when emptyDir medium is edited from disk to Memory: verifies Warning event for emptyDir medium drift.

  • should emit a Warning event when emptyDir medium is edited from Memory to disk: verifies Warning event for emptyDir medium drift.

  • should emit a Warning event when hostPath paths are edited: verifies Warning event for hostPath path changes.

  • should emit a Warning event when a new level is added to spec that worker pod lacks: verifies Warning event for newly added levels.

  • should emit a Warning event when a tieredStore volume exists on pod but was removed from spec: verifies Warning event for orphaned volumes.

  • should throttle warning events and re-emit only after interval expires: verifies rate-limiting within 10 minutes and re-emission after expiration.

  • should reset throttling cooldown when drift is resolved: verifies cooldown reset upon resolution and immediate re-triggering on subsequent drift.

  • should detect drift even when neither CacheRuntime nor template declares worker resources: verifies drift detection runs when workerResources == nil.

  • should return gracefully when podSpec is nil: verifies nil safety.

  • should detect missing volume for processMemory level: verifies missing volume detection.

  • should detect missing volume for hostPath level: verifies missing volume detection for host paths.

  • should return error when reading worker pod spec fails: verifies error propagation and logging when GetPodSpec fails.

  • Integration test in test/gha-e2e/curvine/test.sh (verify_tieredstore_drift_warning): patches cacheruntime curvine-demo emptyDir quota, asserts event emission, and reverts.
  • 100% statement coverage achieved across all new functions and branches.

    Ⅳ. Describe how to verify it

    1. Run unit tests with inlining disabled for gomonkey:

       go test -gcflags="all=-N -l" -v ./pkg/ddc/cache/engine -run TestCacheEngine -ginkgo.focus="tiered store drift"
       

    2. Verify code coverage:
       go test -gcflags="all=-N -l" -coverprofile=coverage.out ./pkg/ddc/cache/engine -run TestCacheEngine -ginkgo.focus="syncRuntimeSpec"
       go tool cover -func=coverage.out | grep -E "checkWorkerTieredStoreDrift|checkEmptyDirDrift|checkProcessMemoryDrift|checkHostPathDrift|findVolume"
       

    Ⅴ. Special notes for reviews

    Client-side tieredStore drift detection (spec.client.tieredStore) is tracked in #6221 as a follow-up, as the client DaemonSet currently uses an OnDelete/immutable model. When the validating webhook (#6193) is disabled, controller event-based detection will provide the detection fallback.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: cheyang Review duration: 5184m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    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.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #6219"
    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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 27.7% · Safe to merge
    27.7%