Skip to content

Commit 68cab10

Browse files
committed
docs(57-02): complete plan 57-02 summary, update tracking after phase 57
Phase 57 (resource-limits) all 3 plans complete: API three-state pointers, PatchResources handler, worker --storage-opt, frontend UI.
1 parent f21b6ea commit 68cab10

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
phase: 57-resource-limits
3+
plan: 02
4+
subsystem: api
5+
tags: [go, nethttp, pointer-semantics, patch, storage-opt, docker]
6+
7+
requires:
8+
- phase: 57-01
9+
provides: "*int/*float64 指针类型 + UpdateHostResources Repository 方法"
10+
provides:
11+
- "Create 端点三态指针语义(nil=默认 / 0=无限制 / 正值=限制)"
12+
- "PatchResources handler(状态检查 + 范围验证 + 事件记录)"
13+
- "Worker --storage-opt 磁盘限制参数生成"
14+
- "移除 runtime_service 双层默认值兜底"
15+
affects: [57-03-ui]
16+
17+
tech-stack:
18+
added: []
19+
patterns:
20+
- "API 层三态解析函数:Create(nil→默认)vs PATCH(nil→不修改)两种语义"
21+
- "Worker 层 0=不传参数(Docker 无限制),>0=传具体参数"
22+
23+
key-files:
24+
created: []
25+
modified:
26+
- internal/agentapi/contracts.go
27+
- internal/runtime/runtime_service.go
28+
- internal/controlplane/http/admin_hosts.go
29+
- internal/controlplane/http/router.go
30+
- internal/runtime/tasks/worker.go
31+
32+
key-decisions:
33+
- "HostActionRequest 资源字段保持非指针(int/float64),三态解析在 API 层完成"
34+
- "Worker 层移除 else 默认值分支:0 值不传 Docker 参数即为无限制"
35+
- "PATCH 范围验证:内存 128-262144 MB、CPU 0.1-64 核、磁盘 1-2048 GB"
36+
37+
requirements-completed:
38+
- RES-02
39+
- RES-04
40+
41+
duration: 20min
42+
completed: 2026-05-31
43+
---
44+
45+
# Phase 57 Plan 02: API 层 + Worker 层 Summary
46+
47+
**Create 端点三态指针语义、PatchResources handler(状态+范围验证)、Worker --storage-opt 磁盘限制**
48+
49+
## Performance
50+
51+
- **Duration:** ~20min
52+
- **Tasks:** 3
53+
- **Files modified:** 5
54+
55+
## Accomplishments
56+
57+
- contracts.go:HostActionRequest 新增 DiskLimitGB 字段
58+
- runtime_service.go:移除 defaultIntIfZero/defaultFloatIfZero 双层默认值兜底,改用 ptrToInt/ptrToFloat 直接透传
59+
- admin_hosts.go:Create body 资源字段改为指针类型(*int/*float64),resolveMemory/resolveCPU/resolveDisk 三态解析;新增 PatchResources handler(status 检查返回 409、范围验证、事件记录)、AdminHostStore 接口扩展
60+
- router.go:注册 PATCH /v1/admin/hosts/{hostID}/resources 路由
61+
- worker.go:移除内存/CPU 的 else 默认值分支,新增 DiskLimitGB > 0 时传 --storage-opt size=XG
62+
63+
## Task Commits
64+
65+
1. **Task 1: contracts.go + runtime_service.go**`bc9dd66` (feat)
66+
2. **Task 2: admin_hosts.go Create + PatchResources**`e0b99fe` (feat)
67+
3. **Task 3: router.go + worker.go**`f21b6ea` (feat)
68+
69+
## Decisions Made
70+
71+
- Worker 移除 else 默认值分支:0 值不传 Docker 参数即为无限制,与移除的双层默认值兜底对齐
72+
- Create 和 PATCH 的三态解析语义不同:Create 的 nil→默认值(4096/2.0/20),PATCH 的 nil→不修改该字段,因此用了两套解析函数
73+
74+
## Deviations from Plan
75+
76+
None — plan executed exactly as written.
77+
78+
## Issues Encountered
79+
80+
None
81+
82+
## Next Phase Readiness
83+
84+
后端 API + Worker 层完整就绪。Phase 57 三个计划全部完成,可进行端到端验证。
85+
86+
---
87+
*Phase: 57-resource-limits*
88+
*Completed: 2026-05-31*

0 commit comments

Comments
 (0)