fix: finalize HWLAB v03 platform DB bridge

This commit is contained in:
Codex
2026-06-09 05:43:57 +00:00
parent ac14d8e7c5
commit 480a7a7b37
4 changed files with 156 additions and 43 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ CI/CD、GitOps、rollout、artifact 发布、PR 合并后的 runtime lane 滚动
当现有 CLI 对某个 CI/CD 操作缺字段、缺动作、缺状态或缺权限时,处理顺序是先补 CLI,再执行发布或治理动作。临时低层 route 写操作只允许用于一次性止血,并且必须随后把稳定能力补进 CLI 与本参考文档;不能把手工 `kubectl apply/delete/annotate`、原生 GitHub CLI、手写 REST 请求或 registry shell 脚本沉淀成长期流程。长时观察仍遵守 60 秒短查询和 submit-and-poll 语义,不用单个 `trans`/`tran` 等待完整 PipelineRun 或 Argo rollout 结束。
`hwlab nodes secret cleanup-owned-postgres --node G14 --lane v03 [--dry-run|--confirm]` 是 v03 迁移到 G14 platform PostgreSQL 后清理旧 repo-owned Postgres StatefulSet/Service/ConfigMap/Secret/PVC 的受控入口。迁移后的 `hwlab-cloud-api-v03-db``hwlab-v03-openfga` SecretRef 来自 G14 host platform DB 凭据文件,不再从 lane-local Postgres Secret 派生;v03+ 的 `hwlab nodes secret ensure --name hwlab-cloud-api-v03-db|hwlab-v03-openfga` 旧路径已删除,status 只做 redacted SecretRef 与 `g14-platform-postgres` bridge 观测。平台 DB 运行、SecretRef 轮换边界和 health 验证见 `docs/reference/g14-platform-db.md`
`hwlab nodes control-plane allow-endpoint-bridge --node G14 --lane v03 [--dry-run|--confirm]` 是 v03 platform PostgreSQL bridge 的受控收敛入口,用于让 Argo 跟踪固定 `EndpointSlice/g14-platform-postgres-host`,并清理旧 `Endpoints/g14-platform-postgres` 及其派生的随机 EndpointSlice。`hwlab nodes secret cleanup-owned-postgres --node G14 --lane v03 [--dry-run|--confirm]` 是 v03 迁移到 G14 platform PostgreSQL 后清理旧 repo-owned Postgres StatefulSet/Service/ConfigMap/Secret/PVC 的受控入口。迁移后的 `hwlab-cloud-api-v03-db``hwlab-v03-openfga` SecretRef 来自 G14 host platform DB 凭据文件,不再从 lane-local Postgres Secret 派生;v03+ 的 `hwlab nodes secret ensure --name hwlab-cloud-api-v03-db|hwlab-v03-openfga` 旧路径已删除,status 只做 redacted SecretRef 与 `g14-platform-postgres` Service、固定 EndpointSlice 和旧 Endpoints 缺席观测。平台 DB 运行、SecretRef 轮换边界和 health 验证见 `docs/reference/g14-platform-db.md`
`hwlab nodes secret status|ensure --node G14 --lane v03 --name hwlab-v03-code-agent-provider` 是 v03 Code Agent / MoonBridge provider SecretRef 的受控 bootstrap 入口;`ensure` 只从集群内既有 `hwlab-v02/hwlab-v02-code-agent-provider` 复制 `openai-api-key``opencode-api-key` 到 lane-local Secret,输出仅披露 source/target Secret 名、key presence、decoded byte count、mutation 和后续命令,禁止打印 base64、解码值、完整 API key 或可复用凭据。OpenFGA 和 master admin API key 继续使用同一命名空间下的 `hwlab nodes secret ... --name hwlab-v03-openfga|hwlab-v03-master-server-admin-api-key`
+13 -3
View File
@@ -48,10 +48,9 @@ PostgreSQL 只监听 G14 host loopback 与 k3s pod 可达的 node gateway 地址
业务 Pod 不直接访问 host IP 字面量,而是访问所在 namespace 内的 `g14-platform-postgres` Service。HWLAB v0.3 的桥接对象在 `hwlab-v03` namespace 中:
- `Service/g14-platform-postgres`
- `Endpoints/g14-platform-postgres`
- `EndpointSlice/g14-platform-postgres-host`
目标地址固定为 `10.42.0.1:5432`。bridge 最低验证标准是 namespace-local `Service/g14-platform-postgres` 存在,并且 `Endpoints``EndpointSlice` 至少一条路径可用;最终仍以 runtime `/health/live``hwlab nodes control-plane status` 的真实连接结果为准,不把某一种端点对象形态做成额外门禁
目标地址固定为 `10.42.0.1:5432`。bridge 最低验证标准是 namespace-local `Service/g14-platform-postgres` 存在、固定 `EndpointSlice/g14-platform-postgres-host` 存在且指向 host PostgreSQL,并且 `Endpoints/g14-platform-postgres` 不存在。不要保留 `Endpoints` 兼容路径或由它派生的随机 EndpointSlice;最终仍以 runtime `/health/live``hwlab nodes control-plane status` 的真实连接结果为准。
业务 SecretRef 固定使用现有应用 Secret 名称,不迁移为共享明文配置:
@@ -85,6 +84,15 @@ bun scripts/cli.ts hwlab nodes control-plane status --node G14 --lane v03 --pipe
Argo Application `hwlab-node-v03` 应显示 `Synced/Healthy`runtime workloads 中应只保留 `service/g14-platform-postgres`,不应再出现 `statefulset.apps/hwlab-v03-postgres``service/hwlab-v03-postgres``configmap/hwlab-v03-postgres-init`
Argo 必须跟踪 `Service/g14-platform-postgres` 和固定 `EndpointSlice/g14-platform-postgres-host`。如果 `argocd-cm` 仍排除或忽略 `Endpoints` / `EndpointSlice`,或者旧 GitOps revision 留下了 `Endpoints/g14-platform-postgres` 与随机派生 EndpointSlice,使用受控入口收敛,不要手工 `kubectl delete`
```bash
bun scripts/cli.ts hwlab nodes control-plane allow-endpoint-bridge --node G14 --lane v03 --dry-run
bun scripts/cli.ts hwlab nodes control-plane allow-endpoint-bridge --node G14 --lane v03 --confirm
```
该入口会移除旧 Argo endpoint 资源排除、重启 Argo application controller、删除旧 `Endpoints/g14-platform-postgres` 和它派生的多余 EndpointSlice,并 hard refresh `hwlab-node-v03`。收敛后的状态必须是 `legacyEndpointsExist=false``hostEndpointSliceExists=true``extraEndpointSlices=[]`
## 旧自有 DB 清理
迁移到平台 DB 后,v0.3 自有 PostgreSQL StatefulSet、Service、ConfigMap、Secret 和 PVC 都必须清理。GitOps render 不再生成旧 `postgres.yaml`;如果运行面仍残留旧对象,直接用受控 CLI 清理精确命名资源,不保留兼容路径:
@@ -108,6 +116,8 @@ trans G14:k3s kubectl -n hwlab-v03 get statefulset,svc,endpoints,endpointslice,c
curl -fsS http://74.48.78.17:20667/health/live | jq '{status, ready, environment, db: {ready: .db.ready, connectionResult: .db.connectionResult}, runtime: {ready: .runtime.ready, queryResult: .runtime.connection.queryResult}}'
```
其中 `endpoints/g14-platform-postgres` 应为空,`endpointslice/g14-platform-postgres-host` 应存在且是唯一带 `kubernetes.io/service-name=g14-platform-postgres` label 的 EndpointSlice。
## 备份与恢复
备份脚本固定在 G14 host
@@ -139,7 +149,7 @@ trans G14 script -- '/usr/local/sbin/g14-platform-db-backup'
- `postgresql` systemd service active。
- `ss -ltnp` 只显示 `127.0.0.1:5432``10.42.0.1:5432` 监听。
- `/usr/local/sbin/g14-platform-db-health` 能列出预期 database。
- `hwlab-v03``g14-platform-postgres` Service 可见,Endpoints 或 EndpointSlice 至少一条 bridge 路径可见
- `hwlab-v03``g14-platform-postgres` Service 可见,`EndpointSlice/g14-platform-postgres-host` 是唯一 bridge endpoint,旧 `Endpoints/g14-platform-postgres` 不存在
- `hwlab-cloud-api` `/health/live` 返回 `status=ok``ready=true``db.connectionResult=connected``runtime.connection.queryResult=durable_readiness_ready`
- `hwlab nodes control-plane status --node G14 --lane v03` 显示 Argo `Synced/Healthy`runtime workload 摘要不包含旧自有 Postgres。