From 3f449eec07d535a68894518deea39a0c4d63a822 Mon Sep 17 00:00:00 2001 From: pikastech Date: Mon, 20 Jul 2026 04:05:26 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=86=20k3s=20worker=20=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E6=94=B9=E4=B8=BA=E7=9F=AD=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .agents/skills/unidesk-cicd/SKILL.md | 1 + docs/reference/platform-infra.md | 1 + scripts/src/platform-infra-k3s-cluster.ts | 7 +++---- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.agents/skills/unidesk-cicd/SKILL.md b/.agents/skills/unidesk-cicd/SKILL.md index 3813545e..b9d2a79e 100644 --- a/.agents/skills/unidesk-cicd/SKILL.md +++ b/.agents/skills/unidesk-cicd/SKILL.md @@ -354,6 +354,7 @@ bun scripts/cli.ts hwlab nodes control-plane legacy-cicd --help - k3s drop-in 未变化且节点容量已收敛时必须 `mutation=false`;禁止无条件重启、重装、强写或通过 CI 自动覆盖同一节点配置。 - WireGuard 配置一致时不得 restart;k3s API/容量暂时不可读时保持 unknown 并停止 mutation,禁止把控制通道抖动解释为配置漂移。 - worker agent 只在 YAML 派生摘要变化或 service 未运行时安装/恢复,不得在每次集群 apply 中先卸载再重装。 + - worker 安装使用短启动并由 control-plane Node Ready 轮询收口,禁止让 `trans`/SSH 长挂等待 systemd notify。 - worker 加入集群不改变 PaC consumer 的 source commit authority,也不授权人工 PipelineRun、Argo sync 或业务 rollout。 - 长命令用异步 job 或短轮询;不要长时间挂住 trans/ssh。 - Web 哨兵 YAML cadence 变更不新增发布 orchestrator:提交前用 `web-probe sentinel validate --local`;合并后用只读 `web-probe sentinel control-plane status --wait`。线上 desired schedule 必须来自 GitOps 清单,不能用操作者旧 worktree 的本地渲染值做阻塞门禁;收敛差异统一为非阻塞 warning。 diff --git a/docs/reference/platform-infra.md b/docs/reference/platform-infra.md index 1e94ccc4..f4094bb5 100644 --- a/docs/reference/platform-infra.md +++ b/docs/reference/platform-infra.md @@ -36,6 +36,7 @@ - 内容一致时保持 `mutation=false`,不得无条件重启、重装或覆盖; - WireGuard 只在配置变化或 unit 未运行时重启/启动,避免短暂断网触发 control-plane 级联重启; - worker agent 以 owning YAML、版本、参数、registry mirror 和 token 的脱敏摘要判断是否需要重装; + - worker 安装只做短启动,终态由 control-plane 的 Node Ready 轮询判定,不得让宿主 SSH 会话等待 systemd notify; - k3s API 暂时不可读属于 unknown,不得当作容量漂移触发 restart; - 集群 CLI 只组合各自 owning domain,不借用全量基础设施入口扩大写入范围。 - 验收: diff --git a/scripts/src/platform-infra-k3s-cluster.ts b/scripts/src/platform-infra-k3s-cluster.ts index fbb09e75..1a99a4e1 100644 --- a/scripts/src/platform-infra-k3s-cluster.ts +++ b/scripts/src/platform-infra-k3s-cluster.ts @@ -288,12 +288,11 @@ install -d -m 700 /etc/rancher/k3s install -m 0600 "$registry_candidate" /etc/rancher/k3s/registries.yaml install -m 0755 /tmp/k3s /usr/local/bin/k3s chmod 0755 /tmp/install-k3s.sh -INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_VERSION=${shQuote(target.worker.k3sVersion)} INSTALL_K3S_EXEC=${shQuote(exec)} sh /tmp/install-k3s.sh -systemctl enable k3s-agent >/dev/null -systemctl restart k3s-agent -systemctl is-active --quiet k3s-agent +INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_SKIP_START=true INSTALL_K3S_VERSION=${shQuote(target.worker.k3sVersion)} INSTALL_K3S_EXEC=${shQuote(exec)} sh /tmp/install-k3s.sh printf '%s\n' "$desired_hash" >"$desired_hash_file" chmod 0600 "$desired_hash_file" +systemctl enable k3s-agent >/dev/null +systemctl restart --no-block k3s-agent `; }