Skip to content

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

Description

@btxu-db

Provide a link to that doc page:

  • docs/zh/samples/cacheruntime/cacheruntime_spec_update.md
  • docs/en/samples/cacheruntime/cacheruntime_spec_update.md

What is the defect and your suggestions on improvement:

Defect

Both docs state that only runtimeVersion and resources support in-place update, and explicitly list replicas under "Unsupported Update Fields" (line 107 in both files), telling readers that "you must redeploy the CacheRuntime for changes to take effect".

This is wrong. replicas is synced in place for Master and Worker, and I verified it both by reading the code and by running it on a live cluster.

Code path

syncRuntimeSpec passes the field into ComponentSpec for both components:

// pkg/ddc/cache/engine/sync.go:205 (Master), :229 (Worker)
masterSpec := component.ComponentSpec{
    Version:   runtime.Spec.Master.RuntimeVersion,
    Resources: resources,
    Replicas:  &runtime.Spec.Master.Replicas,   // always non-nil
}

AdvancedStatefulSetManager.SyncComponentSpec applies it first, before image and resources:

// pkg/ddc/cache/component/advanced_statefulset_manager.go:206
// 1. Update replicas if specified and changed
if newSpec.Replicas != nil {
    if s.updateReplicas(astsToUpdate, *newSpec.Replicas, logger) {
        needsUpdate = true
    }
}

updateReplicas (advanced_statefulset_manager.go:245) compares old vs. new and patches asts.Spec.Replicas when they differ. syncRuntimeSpec is wired into the reconcile loop at sync.go:76, so this runs on every sync — no redeployment is involved.

Note that because Replicas is always passed as a non-nil pointer, this path is unconditional for Master and Worker (when the component is enabled), unlike resources, which is only synced when the user has explicitly set it.

Verified on a live cluster

kind cluster, cacheruntime-controller:v1.1.0-versionfix, target bugtest/bugtest7.
Patched spec.worker.replicas from 1 to 2 with kubectl patch — 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 carry the same reconcileID: ceed3efb-e35b-4e3b-9cac-85943422149c, so the ASTS change is attributable to this code path rather than to a coincidental helm/setup re-apply. Within ~15s the ASTS reported spec.replicas=2 and pod bugtest7-worker-1 was created. Patching back to 1 produced the mirror-image log (old: 2, new: 1) and the pod was removed.

For contrast, the periodic reconciles that ran while the spec was unchanged (06:26:23, 06:27:53, 06:29:23) all logged no spec changes detected, skip update — the sync is value-driven, so it is a no-op until the field actually changes.

Affected locations

Identical line numbers in the zh and en files:

Line Claim
7 "supports in-place updates for only the following two fields"
98 "Aside from runtimeVersion and resources, modifying any other fields ... will not propagate"
107 replicas listed as unsupported
122 Summary table: "All other fields — No"
125 "supports dynamic updates for only runtimeVersion and resources"

Suggested fix

  1. Move replicas out of the unsupported list in section 4 into section 3 ("Supported Update Fields") as its own subsection, alongside runtimeVersion and resources.
  2. Update the counts at lines 7, 98 and 125 from two fields to three.
  3. Add a summary-table row: replicas | Yes | Automatically synced to AdvancedStatefulSet.
  4. Keep the scope explicit: Master and Worker only. The Client component uses a DaemonSet and has no replica field, so the existing statement about Client remains correct.

Side note

The TODO at pkg/ddc/cache/engine/sync.go:67 — // TODO: implement other logic like inplace update and replica scaling — sits directly above the syncRuntimeSpec call that implements exactly that, and looks equally stale. Worth removing in the same pass.

No activity

Activity on this issue will appear here.

Activity

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

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions