feat: add NC01 registry retention GC

This commit is contained in:
pikastech
2026-07-21 07:14:22 +02:00
parent 9471f43b45
commit 03c96bec19
6 changed files with 529 additions and 83 deletions
+12
View File
@@ -42,6 +42,18 @@
- 按目标节点 `kubernetesObjectRetention` YAML 规划和异步回收 Kubernetes 历史对象;
- `plan` 与手动、自动 `run` 必须复用同一个 fail-closed 筛选器;
- 表格形状、时间或分组无法识别时保护对象并停止删除。
- `gc remote <providerId> plan --include-registry`
-`config/unidesk-cli.yaml#gc.remote.targets.<providerId>.registryRetention` 读取留存策略;
- 通过显式 `configRef` 读取 node-local registry 的 endpoint、Deployment、namespace 和 PVC
- 保护当前 workload tag/digest refs、近期 tag、每仓库最新 tag、保护仓库和 digest closure
- 输出候选 manifest、保护原因、估算收益和 typed diagnosis
- 不支持的目标、PVC 未绑定、存储布局不可读或 workload 形状漂移时必须 fail closed。
- `gc remote <providerId> run --confirm --include-registry`
- 作为异步 job 返回,并通过 `gc remote <providerId> status --job-id <id>` 短查询;
- 只通过 Registry API 删除 plan 中不受保护的 manifest
- 对 YAML 声明的 Registry Deployment 缩容后运行官方 `registry garbage-collect`
- PVC 只挂载给 GC Pod,不删除 PVC、PV、blob 目录、containerd 或 k3s storage
- 无论成功或失败都恢复原副本数,并复核 Deployment readiness 与 `/v2/` endpoint。
- `--include-tool-caches`:本机和远端都必须是显式 opt-in,只清理固定 allowlist 的可重建 npm/npx/Bun 缓存;不得扩大成清理 `~/.npm``~/.bun``node_modules`、auth/config 或运行面依赖。
所有成功和失败输出都必须是 JSON。`plan` 必须标记 `dryRun=true``mutation=false``run` 必须要求 `--confirm` 并报告 `diskBefore``diskAfter``summary``results``protected`。远端 GC 可用 `--target-use-percent N` 显式表达目标根盘水位;`summary.target` 必须给出目标所需释放量、候选估算、预计水位、缺口和 `safeStop` 决策,避免靠人工心算判断是否应该继续扩大清理范围。