Skip to content

docs: list the fields CacheRuntime can update in place, and stop enumerating the rest - #6183

Open
btxu-db wants to merge 1 commit into
fluid-cloudnative:masterfrom
btxu-db:docs/cacheruntime-replicas-in-place
Open

docs: list the fields CacheRuntime can update in place, and stop enumerating the rest#6183
btxu-db wants to merge 1 commit into
fluid-cloudnative:masterfrom
btxu-db:docs/cacheruntime-replicas-in-place

Conversation

@btxu-db

@btxu-db btxu-db commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Fixes #6182.

docs/{zh,en}/samples/cacheruntime/cacheruntime_spec_update.md state that only runtimeVersion and resources can be updated in place, and list replicas among the fields that need a redeploy. replicas is actually synced on every reconcile:

  • pkg/ddc/cache/engine/sync.go:199,236 pass &runtime.Spec.{Master,Worker}.Replicas into ComponentSpec — always non-nil, unlike resources
  • SyncComponentSpec applies it first, through updateReplicas, and patches the AdvancedStatefulSet when the value differs
  • syncRuntimeSpec is called from the reconcile loop at sync.go:76

Verified on a kind cluster. Patching spec.worker.replicas from 1 to 2, with no redeploy:

06:29:25.421  advanced_statefulset_manager.go:251  replicas changed, will update   old: 1  new: 2
06:29:25.427  advanced_statefulset_manager.go:239  successfully patched advanced statefulset with new spec

Both lines share one reconcileID, so the AdvancedStatefulSet change comes from this path and not from a coincidental re-apply. The new replica appeared within ~15s; patching back to 1 produced the mirror-image log and removed the pod. Reconciles that ran while the spec was unchanged logged no spec changes detected, skip update, so the sync is value-driven rather than a periodic overwrite.

Changes

  • Give replicas its own subsection 3.3, matching the layout of 3.1 and 3.2
  • Update the field counts in the overview, section 2 and the summary table
  • Name runtimeVersion and resources explicitly in key takeaway 2, which said "these two fields" and became ambiguous once a third was added
  • Replace section 4's enumerated list of unsupported fields with a reference to section 3
  • Remove the stale // TODO: implement other logic like inplace update and replica scaling sitting directly above the syncRuntimeSpec call that implements it

Why section 4 changed

Section 4 listed the unsupported fields one by one. Keeping that list correct meant remembering, every time a field became syncable, to go and delete a line from a section unrelated to the change — nothing in the code or CI prompts for it. The stale replicas entry is what that looks like in practice, and the list was already labelled "including but not limited to", so it could never be authoritative anyway.

It now points at section 3 rather than restating it: section 3 is the only place a supported field is recorded, and adding one no longer requires an edit elsewhere to stay accurate.

Notes for reviewers

Section 3.3 records two limitations that are not in the code as comments, and I would appreciate a check on both:

  • Scaling in loses cache. There is no drain or migration step on this path — grep -rn "ScaleDown|destroyWorker|drain" pkg/ddc/cache/ finds nothing — so a removed Worker's cached data has to be reloaded from the underlying storage. This is inferred from the absence of handling rather than measured; I only exercised scale-out and the rollback.
  • Scaling is silent. Unlike pkg/ctrl/replicas.go:SyncReplicas, which records a RuntimeWorkerScaledIn/ScaledOut condition and emits an Event, this path does neither. Documenting it makes current behaviour discoverable, but if the intent is to add conditions and events later, that line should come out again.

The replicas row in the summary table is the only place resources and replicas sit side by side, so it is worth confirming the wording does not imply replicas carries the K8s >= 1.27 requirement — it does not.

@fluid-e2e-bot

fluid-e2e-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

Hi @btxu-db. 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.

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.24%. Comparing base (f2785f8) to head (6bcf188).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6183   +/-   ##
=======================================
  Coverage   65.24%   65.24%           
=======================================
  Files         486      486           
  Lines       34194    34194           
=======================================
  Hits        22309    22309           
  Misses      10135    10135           
  Partials     1750     1750           

☔ 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.

@btxu-db
btxu-db force-pushed the docs/cacheruntime-replicas-in-place branch from 0a27cfc to 2fc529e Compare September 5, 2026 10:48
@btxu-db btxu-db changed the title docs: replicas is updated in place, not only runtimeVersion and resources docs: list the fields CacheRuntime can update in place, and stop enumerating the rest Sep 5, 2026
cheyang
cheyang previously approved these changes Sep 9, 2026

@cheyang cheyang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read this against the code and it holds up. syncRuntimeSpec passes &runtime.Spec.{Master,Worker}.Replicas into ComponentSpec on every reconcile (always non-nil, unlike resources), and SyncComponentSpec patches the AdvancedStatefulSet through updateReplicas when the value differs. So moving replicas into section 3 is correct and the old section-4 entry really was stale.

I ran the actual sync path against a fake client to confirm both Master and Worker, both scale directions, and that an unchanged count is a no-op rather than a periodic overwrite. I also checked the two things you called out for review: this path records no RuntimeCondition and emits no Event (unlike pkg/ctrl/replicas.go), and there is no drain or migration on scale-in, so both limitations in 3.3 read accurately. The deploy/cacheruntime-controller + grep "replicas changed" command matches the chart and the Info-level log line, and collapsing section 4 into a pointer at section 3 is safe because SyncComponentSpec touches exactly those three fields.

One non-blocking thought: 3.3 documents Master replicas as in-place-updatable and the code does sync it, but you mentioned only exercising Worker live. Fine to leave as-is since it is confirmed in the code path.

LGTM.

@cheyang
cheyang dismissed their stale review September 9, 2026 03:39

Superseded: found a doc inaccuracy in §3.3 (observability) after approving; switching to request changes with the correction.

@fluid-e2e-bot

fluid-e2e-bot Bot commented Sep 9, 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 trafalgarzzz for approval by writing /assign @trafalgarzzz 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 removed the approved label Sep 9, 2026

@cheyang cheyang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching my earlier approval to a change request — I dug into the observability claim in §3.3 after approving and one line is inaccurate. Everything else holds up: I ran the real sync path against a fake client and confirmed replicas is synced in place for both Master and Worker, in both scale directions, value-driven rather than a periodic overwrite, and the section-4 whitelist rewrite is sound. The fix below is minor, but it's a factual error in a doc whose whole job is to be accurate, and the project already documents the status-based observability path elsewhere, so worth correcting before merge. Details inline.


**Limitations**:
- ⚠️ **Scaling in discards cached data**: the Worker Pods removed are deleted outright, and the data they had cached is not migrated to the remaining Workers — it has to be loaded from the underlying storage again. Scaling out leaves the existing cache untouched.
- ⚠️ Scaling writes no RuntimeCondition and emits no Kubernetes Event; it can only be observed from the controller logs:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "no RuntimeCondition / no Event" half is right, but "can only be observed from the controller logs" isn't. The reconcile writes replica counts to the CacheRuntime status on every loop: ConstructComponentStatus derives desiredReplicas from the ASTS spec.replicas, setWorkerComponentStatus/setMasterComponentStatus assign it to status.{worker,master}, and CheckAndUpdateRuntimeStatus persists it. Your own curvine_cache_runtime.md (line 573) already reads scaling this way: kubectl get cacheruntime ... -o jsonpath='{.status.worker.readyReplicas}/{.status.worker.desiredReplicas}'. Suggest: "Scaling writes no RuntimeCondition and emits no Kubernetes Event. Progress can be observed through status.{master,worker}.{readyReplicas,desiredReplicas} or the controller logs:"


**限制**:
- ⚠️ **缩容会丢失缓存数据**:被缩掉的 Worker Pod 直接删除,其上已缓存的数据不会迁移到其余 Worker,需要重新从底层存储加载。扩容不影响已有缓存。
- ⚠️ 扩缩容不会写入 RuntimeCondition,也不会产生 Kubernetes Event,只能从 controller 日志观察:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same fix as the English side: drop "只能从 controller 日志观察" and mention the status fields, e.g. "扩缩容不会写入 RuntimeCondition,也不会产生 Kubernetes Event。可以通过 status.{master,worker}.{readyReplicas,desiredReplicas} 或 controller 日志观察进度:"

…erating the rest

The spec update doc listed `replicas` under "Unsupported Update Fields" and told
readers a redeploy was required. It is in fact synced on every reconcile:
syncRuntimeSpec passes it into ComponentSpec for Master and Worker, and
SyncComponentSpec applies it through updateReplicas before image and resources.

Give `replicas` its own subsection in section 3, alongside runtimeVersion and
resources, and record the two things worth knowing before scaling: cache on a
removed Worker is discarded rather than migrated, and scaling writes no
RuntimeCondition and emits no Event, though progress is visible in
status.{master,worker}.{readyReplicas,desiredReplicas} and the controller log.

Section 4 used to enumerate the unsupported fields. Keeping that list correct
meant remembering, every time a field became syncable, to delete a line from a
section unrelated to the change, with nothing in the code or CI to prompt for
it — which is how the `replicas` entry survived. It was also labelled
"including but not limited to", so it could not be authoritative anyway.
Section 4 now refers to section 3 instead of repeating it, leaving one place
where a supported field is recorded.

Also drop the TODO above the syncRuntimeSpec call asking for the replica
scaling that the call already does.

Signed-off-by: btxu-db <btxu-db@outlook.com>
@btxu-db
btxu-db force-pushed the docs/cacheruntime-replicas-in-place branch from 2fc529e to 6bcf188 Compare September 9, 2026 06:50
@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

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.

[DOC]CacheRuntime spec update doc lists replicas as non-updatable, but it is synced in-place

2 participants