diff --git a/config/unidesk-cli.yaml b/config/unidesk-cli.yaml index 8b3aefe0..5393e50e 100644 --- a/config/unidesk-cli.yaml +++ b/config/unidesk-cli.yaml @@ -193,8 +193,9 @@ gc: enabled: false reason: NC01 主机 Docker 承载主服务运行面,通用远端 GC 不得截断活跃服务日志。 buildCachePrune: - enabled: false - reason: NC01 不是通用构建主机,通用远端 GC 不得清理其活跃 Docker 状态。 + enabled: true + until: 24h + reason: 仅回收超过 YAML 年龄阈值且 Docker 判定可回收的 BuildKit cache;不清理 images、containers 或 volumes。 memoryPressure: planPreviewLimit: 6 processPatterns: diff --git a/docs/reference/gc.md b/docs/reference/gc.md index 801286b4..27a533f2 100644 --- a/docs/reference/gc.md +++ b/docs/reference/gc.md @@ -137,7 +137,7 @@ Worktree 清理由 `--include-merged-worktrees` 显式启用,只扫描 `config - systemd journal vacuum 到目标上限。 - Docker `json-file` 日志截断。 -- Docker BuildKit cache prune,默认只清理超过 `--build-cache-until` 的 cache。 +- Docker BuildKit cache prune 只清理 owning YAML `hostDockerGc.buildCachePrune.until` 声明年龄之外的 cache;显式 `--build-cache-until` 可覆盖本次计划,不清理 images、containers 或 volumes。 - apt archive clean。 - allowlisted `/tmp` 诊断目录删除。 - 受限 core dump 删除。 diff --git a/scripts/src/gc-remote-runner.py b/scripts/src/gc-remote-runner.py index eaf12c45..297e1bc0 100644 --- a/scripts/src/gc-remote-runner.py +++ b/scripts/src/gc-remote-runner.py @@ -1192,7 +1192,7 @@ def collect_candidates(observed_at): if system_df["exitCode"] == 0: cache = parse_docker_build_cache(system_df["stdout"]) if cache is not None and cache["reclaimableBytes"] > 0: - until = str(OPTIONS.get("buildCacheUntil") or "24h") + until = str(OPTIONS.get("buildCacheUntil") or host_docker_gc_section("buildCachePrune").get("until") or "24h") candidates.append({ "id": "docker-builder:prune", "kind": "docker-build-cache-prune", @@ -1588,7 +1588,7 @@ def execute(candidate): if kind == "docker-build-cache-prune": if not host_docker_gc_enabled("buildCachePrune"): raise RuntimeError(host_docker_gc_reason("buildCachePrune", "refusing Docker builder prune on this provider")) - until = str(OPTIONS.get("buildCacheUntil") or "24h") + until = str(OPTIONS.get("buildCacheUntil") or host_docker_gc_section("buildCachePrune").get("until") or "24h") result = command(["docker", "builder", "prune", "--all", "--force", "--filter", "until=%s" % until], 45) if result["exitCode"] != 0: raise RuntimeError((result["stderr"] or "docker builder prune failed").strip()) diff --git a/scripts/src/gc-remote.ts b/scripts/src/gc-remote.ts index 3390a16f..b9b52586 100644 --- a/scripts/src/gc-remote.ts +++ b/scripts/src/gc-remote.ts @@ -47,7 +47,7 @@ const DEFAULT_REMOTE_OPTIONS: RemoteGcOptions = { dockerLogs: true, dockerLogMaxBytes: 50 * 1024 * 1024, buildCache: true, - buildCacheUntil: "24h", + buildCacheUntil: "", tmp: true, tmpMinAgeHours: 24, toolCaches: false,