Skip to content

Commit 2fc529e

Browse files
committed
docs: list the fields CacheRuntime can update in place, and stop enumerating 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, so the controller log is the only place to observe it. 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>
1 parent f2785f8 commit 2fc529e

3 files changed

Lines changed: 76 additions & 40 deletions

File tree

docs/en/samples/cacheruntime/cacheruntime_spec_update.md

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
This document describes which `spec` fields of the CacheRuntime's Master and Worker components (backed by **AdvancedStatefulSet**) can be updated in-place.
66

7-
The current version supports in-place updates for only the following two fields:
7+
The current version supports in-place updates for the following three fields:
88
- **Container image** (`runtimeVersion`)
99
- **Resource limits** (`resources`)
10+
- **Replica count** (`replicas`)
1011

1112
Modifications to other fields **will not be propagated to the AdvancedStatefulSet** and require redeployment to take effect.
1213

@@ -16,12 +17,12 @@ Modifications to other fields **will not be propagated to the AdvancedStatefulSe
1617

1718
| Component | Workload Type | Field Update Support |
1819
|-----------|---------------|---------------------|
19-
| **Master** | AdvancedStatefulSet | ✅ Supports `runtimeVersion` and `resources` |
20-
| **Worker** | AdvancedStatefulSet | ✅ Supports `runtimeVersion` and `resources` |
20+
| **Master** | AdvancedStatefulSet | ✅ Supports `runtimeVersion`, `resources` and `replicas` |
21+
| **Worker** | AdvancedStatefulSet | ✅ Supports `runtimeVersion`, `resources` and `replicas` |
2122
| **Client** | DaemonSet | ❌ Not supported (any changes require redeployment) |
2223

2324
**Notes**:
24-
- Modifying `runtimeVersion` and `resources` on Master and Worker components automatically propagates to the underlying AdvancedStatefulSet.
25+
- Modifying `runtimeVersion`, `resources` and `replicas` on Master and Worker components automatically propagates to the underlying AdvancedStatefulSet.
2526
- The Client component uses a DaemonSet and does not support dynamic updates.
2627

2728
---
@@ -104,23 +105,40 @@ spec:
104105
```
105106
See [Kubernetes Issue #127356](https://github.com/kubernetes/kubernetes/issues/127356).
106107

107-
## 4. Unsupported Update Fields
108+
---
109+
110+
### 3.3 Replica Count (`replicas`)
111+
112+
**Field path**: `spec.{master,worker}.replicas`
113+
114+
**Example**:
115+
```yaml
116+
spec:
117+
worker:
118+
replicas: 3
119+
```
120+
121+
```bash
122+
kubectl patch cacheruntime my-cache --type='merge' -p '{"spec":{"worker":{"replicas":3}}}'
123+
```
108124

109-
Aside from `runtimeVersion` and `resources`, **modifying any other fields in the CacheRuntime spec will not propagate to the AdvancedStatefulSet**, including but not limited to:
125+
The new value is synced to the AdvancedStatefulSet's `spec.replicas`, which then performs the scaling.
126+
127+
**Limitations**:
128+
- ⚠️ **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.
129+
- ⚠️ Scaling writes no RuntimeCondition and emits no Kubernetes Event; it can only be observed from the controller logs:
130+
```bash
131+
kubectl -n fluid-system logs deploy/cacheruntime-controller | grep "replicas changed"
132+
```
133+
- ⚠️ If the replica count exceeds the number of schedulable nodes, the surplus Worker Pods stay `Pending`.
134+
135+
## 4. Unsupported Update Fields
110136

111-
- `env`: Environment variables
112-
- `podMetadata`: Pod metadata (labels/annotations)
113-
- `args`/`command`: Container startup arguments
114-
- `ports`: Container ports
115-
- `volumeMounts`/`volumes`: Storage configuration
116-
- `nodeSelector`/`tolerations`/`affinity`: Scheduling configuration
117-
- `securityContext`: Security context
118-
- `replicas`: Replica count
119-
- `disabled`: Component enabled/disabled status
137+
**Any field not listed in section 3 cannot be updated in place**; changes to it are not propagated to the AdvancedStatefulSet.
120138

121139
**Notes**:
122-
- After modifying these fields, you must redeploy the CacheRuntime for changes to take effect.
123-
- The system does not automatically detect or propagate changes to these fields.
140+
- Such a field takes effect only after the CacheRuntime is redeployed.
141+
- The system does not automatically detect or propagate these changes.
124142

125143
---
126144

@@ -130,9 +148,10 @@ Aside from `runtimeVersion` and `resources`, **modifying any other fields in the
130148
|-------|-----------|---------------|
131149
| `runtimeVersion` | ✅ Yes | Automatically synced to AdvancedStatefulSet |
132150
| `resources` | ✅ Yes | Automatically synced to AdvancedStatefulSet (requires K8s >= 1.27) |
151+
| `replicas` | ✅ Yes | Automatically synced to AdvancedStatefulSet (scaling in discards that Worker's cache) |
133152
| All other fields | ❌ No | Not synced; redeployment required |
134153

135154
**Key Takeaways**:
136-
1. The current version supports dynamic updates for only `runtimeVersion` and `resources`.
137-
2. In cgroupv1 environments, these two fields must be updated separately (step-by-step).
155+
1. The current version supports dynamic updates for `runtimeVersion`, `resources` and `replicas`.
156+
2. In cgroupv1 environments, `runtimeVersion` and `resources` must be updated separately (step-by-step); `replicas` is not subject to this limitation.
138157
3. Modifications to other fields will not take effect and require redeployment.

docs/zh/samples/cacheruntime/cacheruntime_spec_update.md

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
本文档说明 CacheRuntime 的 Master 和 Worker 组件(基于 **AdvancedStatefulSet**)支持的 spec 字段更新能力。
66

7-
当前版本仅支持以下两个字段的原地更新
7+
当前版本支持以下三个字段的原地更新
88
- **容器镜像** (`runtimeVersion`)
99
- **资源限制** (`resources`)
10+
- **副本数** (`replicas`)
1011

1112
其他字段的修改**不会同步到 AdvancedStatefulSet**,需要重新部署才能生效。
1213

@@ -16,12 +17,12 @@
1617

1718
| 组件 | 工作负载类型 | 字段更新支持 |
1819
|------|-------------|------------|
19-
| **Master** | AdvancedStatefulSet | ✅ 支持 `runtimeVersion``resources` |
20-
| **Worker** | AdvancedStatefulSet | ✅ 支持 `runtimeVersion``resources` |
20+
| **Master** | AdvancedStatefulSet | ✅ 支持 `runtimeVersion``resources``replicas` |
21+
| **Worker** | AdvancedStatefulSet | ✅ 支持 `runtimeVersion``resources``replicas` |
2122
| **Client** | DaemonSet | ❌ 不支持(任何变更都需重新部署) |
2223

2324
**说明**
24-
- Master 和 Worker 的 `runtimeVersion``resources` 字段修改会自动同步到 AdvancedStatefulSet
25+
- Master 和 Worker 的 `runtimeVersion``resources``replicas` 字段修改会自动同步到 AdvancedStatefulSet
2526
- Client 组件使用 DaemonSet,不支持动态更新
2627

2728
---
@@ -103,23 +104,40 @@ spec:
103104
```
104105
详见 [Kubernetes Issue #127356](https://github.com/kubernetes/kubernetes/issues/127356)。
105106

106-
## 4. 不支持更新的字段
107+
---
108+
109+
### 3.3 副本数 (`replicas`)
110+
111+
**字段路径**: `spec.{master,worker}.replicas`
112+
113+
**示例**:
114+
```yaml
115+
spec:
116+
worker:
117+
replicas: 3
118+
```
119+
120+
```bash
121+
kubectl patch cacheruntime my-cache --type='merge' -p '{"spec":{"worker":{"replicas":3}}}'
122+
```
107123

108-
除 `runtimeVersion` 和 `resources` 外,**修改 CacheRuntime spec 中的其他字段不会同步到 AdvancedStatefulSet**,包括但不限于:
124+
修改后同步到 AdvancedStatefulSet 的 `spec.replicas`,由其完成扩缩容。
125+
126+
**限制**:
127+
- ⚠️ **缩容会丢失缓存数据**:被缩掉的 Worker Pod 直接删除,其上已缓存的数据不会迁移到其余 Worker,需要重新从底层存储加载。扩容不影响已有缓存。
128+
- ⚠️ 扩缩容不会写入 RuntimeCondition,也不会产生 Kubernetes Event,只能从 controller 日志观察:
129+
```bash
130+
kubectl -n fluid-system logs deploy/cacheruntime-controller | grep "replicas changed"
131+
```
132+
- ⚠️ 副本数超过可调度节点数时,多余的 Worker Pod 会一直处于 Pending。
133+
134+
## 4. 不支持更新的字段
109135

110-
- `env`: 环境变量
111-
- `podMetadata`: Pod 元数据(labels/annotations)
112-
- `args`/`command`: 容器启动参数
113-
- `ports`: 容器端口
114-
- `volumeMounts`/`volumes`: 存储配置
115-
- `nodeSelector`/`tolerations`/`affinity`: 调度配置
116-
- `securityContext`: 安全上下文
117-
- `replicas`: 副本数
118-
- `disabled`: 组件启用状态
136+
**第 3 节未列出的字段一律不支持原地更新**,修改后不会同步到 AdvancedStatefulSet。
119137

120138
**说明**:
121-
- 修改这些字段后,需要重新部署 CacheRuntime 才能生效
122-
- 系统不会自动检测或同步这些字段的变更
139+
- 这类字段修改后,需要重新部署 CacheRuntime 才能生效
140+
- 系统不会自动检测或同步这类变更
123141

124142
---
125143

@@ -129,9 +147,10 @@ spec:
129147
|------|------------|---------|
130148
| `runtimeVersion` | ✅ 支持 | 自动同步到 AdvancedStatefulSet |
131149
| `resources` | ✅ 支持 | 自动同步到 AdvancedStatefulSet(需 K8s >= 1.27) |
150+
| `replicas` | ✅ 支持 | 自动同步到 AdvancedStatefulSet(缩容会丢失该 Worker 上的缓存) |
132151
| 其他所有字段 | ❌ 不支持 | 不会同步,需重新部署 |
133152

134153
**关键要点**:
135-
1. 当前版本仅支持 `runtimeVersion` 和 `resources` 两个字段的动态更新
136-
2. Cgroupv1 环境需分步更新这两个字段
154+
1. 当前版本支持 `runtimeVersion`、`resources` 和 `replicas` 三个字段的动态更新
155+
2. Cgroupv1 环境需分步更新 `runtimeVersion` 和 `resources`,`replicas` 不受此限制
137156
3. 其他字段的修改不会生效,必须重新部署

pkg/ddc/cache/engine/sync.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ func (e *CacheEngine) Sync(ctx cruntime.ReconcileRequestContext) (err error) {
6464
return err
6565
}
6666

67-
// TODO: implement other logic like inplace update and replica scaling
68-
6967
// Use lightweight getRuntimeStatusValue instead of full transform for status update
7068
statusValue, err := e.getRuntimeStatusValue(runtime, runtimeClass)
7169
if err != nil {

0 commit comments

Comments
 (0)