Skip to content

fix(cache): restore Dataset to Bound after CacheRuntime recovers from an outage - #6162

Open
pujitha24 wants to merge 1 commit into
fluid-cloudnative:masterfrom
pujitha24:auto/issue-6160
Open

fix(cache): restore Dataset to Bound after CacheRuntime recovers from an outage#6162
pujitha24 wants to merge 1 commit into
fluid-cloudnative:masterfrom
pujitha24:auto/issue-6160

Conversation

@pujitha24

Copy link
Copy Markdown

Ⅰ. Describe what this PR does

Fixes a bug where a CacheRuntime-backed Dataset gets permanently stuck in Failed
phase after a transient runtime outage (e.g. a worker pod restart), even after the
runtime becomes Ready again.

Root cause: in pkg/ddc/cache/engine/sync.go, CacheEngine.Sync sets the Dataset to
Failed whenever the runtime isn't ready, but when the runtime becomes ready again it
only calls syncDatasetCacheStates, which never touches .Status.Phase. The Bound
phase is otherwise only set once, by BindToDataset during the initial Setup(),
which does not run again on subsequent reconciles. So once a Dataset flips to Failed,
nothing ever flips it back to Bound, even though the underlying runtime has fully
recovered.

The fix checks, on every reconcile where the runtime is ready, whether the Dataset is
currently Failed; if so it restores it to Bound via the existing
UpdateDatasetStatus helper (the same helper BindToDataset uses), instead of only
refreshing cache states.

Ⅱ. Does this pull request fix one issue?

fixes #6160

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

Added a Ginkgo test in pkg/ddc/cache/engine/sync_test.go:
"when runtime is ready but dataset was left Failed by a previous outage" — it seeds a
Dataset with Status.Phase = FailedDatasetPhase, makes the master/worker
StatefulSets report Ready, runs engine.Sync(ctx), and asserts the Dataset's phase is
restored to Bound.

I confirmed this test is a genuine regression test for the bug: with only the test
added and the sync.go fix reverted, it fails with Failed != Bound; with the fix
applied, it passes.

Ⅳ. Describe how to verify it

Commands run locally (all passed):

  • go build ./...
  • go vet ./pkg/ddc/cache/...
  • gofmt -l pkg/ddc/cache/engine/sync.go pkg/ddc/cache/engine/sync_test.go (no output)
  • golangci-lint run ./pkg/ddc/cache/... → "0 issues"
  • go test ./pkg/ddc/cache/engine/... -run TestCacheEngine --ginkgo.focus="left Failed by a previous outage" -v → PASS

Note: running the full pkg/ddc/cache/engine suite unfocused shows some pre-existing,
order-dependent flaky failures in ufs_test.go/dataset_test.go/fileutils_test.go
(unrelated files). These reproduce identically on unmodified master with the same
random spec ordering (verified by stashing this change and rerunning), so they are not
caused by this change.

I did not reproduce this against a live cluster; the fix and its regression test are
scoped to a single, deterministic phase-transition defect in Sync, which the
focused unit test above demonstrates directly.

Ⅴ. Special notes for reviews

None.

… an outage

Motivation:
A CacheRuntime-backed Dataset that flips to Failed during a transient
runtime outage (e.g. a worker pod restart) never returns to Bound, even
after the runtime becomes fully Ready again. Only deleting and
recreating the CacheRuntime restored the correct state.

Approach:
CacheEngine.Sync only refreshed cache states when the runtime was
ready, without touching the Dataset's phase. The Bound phase was
otherwise only ever set once, by BindToDataset during initial Setup,
which does not run again on later reconciles, so the Failed phase was
a one-way trap. Sync now checks the Dataset's current phase whenever
the runtime is ready and, if it is Failed, restores it to Bound via
the existing UpdateDatasetStatus helper before falling back to the
regular cache-states sync.

Validation:
- go build ./...
- go vet ./pkg/ddc/cache/...
- gofmt -l pkg/ddc/cache/engine/sync.go pkg/ddc/cache/engine/sync_test.go (no output)
- golangci-lint run ./pkg/ddc/cache/... -> 0 issues
- go test ./pkg/ddc/cache/engine/... -run TestCacheEngine --ginkgo.focus="left Failed by a previous outage" -v -> PASS
- Confirmed the new test is a genuine regression test: reverting only
  sync.go while keeping the new test makes it fail with Failed != Bound
- Full unfocused suite in this package shows pre-existing, order-dependent
  flaky failures in ufs_test.go/dataset_test.go/fileutils_test.go that
  reproduce identically on unmodified master, unrelated to this change

Report: fluid-cloudnative#6160
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@fluid-e2e-bot

fluid-e2e-bot Bot commented Aug 15, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign zwwhdls for approval by writing /assign @zwwhdls in a comment. For more information see:The Kubernetes Code Review Process.

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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fluid-e2e-bot

fluid-e2e-bot Bot commented Aug 15, 2026

Copy link
Copy Markdown

Hi @pujitha24. Thanks for your PR.

I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.19%. Comparing base (a38da8a) to head (49b2a77).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/ddc/cache/engine/sync.go 57.14% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6162      +/-   ##
==========================================
+ Coverage   65.13%   65.19%   +0.06%     
==========================================
  Files         485      485              
  Lines       34039    34053      +14     
==========================================
+ Hits        22171    22202      +31     
+ Misses      10127    10108      -19     
- Partials     1741     1743       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]CacheRuntime: Dataset stays Failed after the runtime recovers

1 participant