fix(deploy): repair missing router public-key path after partial activation

Live evidence showed a healthy candidate connector and a restarting router:
legacy router environment omitted HN_CONNECTOR_PUBLIC_KEY, so the new routing
verifier tried runtime/pki/connector.pub instead of the existing /trust mount.

Resolve the public key from the existing read-only trust bind, set its path
in new overlays, and actually load it during isolated runtime checks. Add
repair-router for a known healthy candidate connector: preserve credential
keys and live configuration, back up overlay/plan, add only the router path,
update integrity metadata, probe, and recreate router alone with --no-deps.
Retries do not regenerate keys or overwrite repair backups.

Add read-only state including stopped/restarting containers and fixed startup
error classes, including stderr, without printing raw logs or credentials.
Identify command stage/exit code and activation progress. Permit rollback
of known stopped candidate targets and old overlays without requiring the
new router key; unknown images still fail closed.

Validation: full suite 262 passed, 3 skipped (real PostgreSQL unavailable),
30 existing warnings; final tooling suite 50 passed after the added CLI
rollback regression. Python 3.7 syntax and staged diff checks pass.
No live repair was executed by this agent; operator must run repair-router
and verify health and the real client handshake on ECS.
This commit is contained in:
ex_tianzy
2026-11-04 16:27:47 +08:00
parent 2657146334
commit 8a94d60155
4 changed files with 332 additions and 17 deletions
+24
View File
@@ -102,6 +102,30 @@ sudo python3 deployable/scripts/broker_deploy.py activate \
## 6. 应急容器回退
### 已部分切换且router缺少公钥参数
现场已确认一种旧配置兼容遗漏:connector候选健康,router不断重启,日志报`FileNotFoundError: runtime/pki/connector.pub`;router原环境仅有`HN_CA_CERT=/trust/ca.pem`,没有`HN_CONNECTOR_PUBLIC_KEY`。不要修改公钥内容、重新生成CA或keyring,不要重复activate。
更新暂存仓库后可先只读查看包含停止/重启中容器的状态和固定错误类型:
```bash
sudo python3 deployable/scripts/broker_deploy.py state \
--plan /home/cnooc/hainuo-broker-prepared-20261104
```
仅在已知候选connector运行且healthy时执行:
```bash
sudo python3 deployable/scripts/broker_deploy.py repair-router \
--plan /home/cnooc/hainuo-broker-prepared-20261104
```
该操作先验证原配置/密钥/准备目录完整性及已知候选镜像,从router已有只读信任挂载识别实际公钥位置(该现场为`/trust/connector.pub`),备份原叠加和plan后只增加router公钥参数并同步计划校验。不会重生成任何密钥、修改原.env、重建connector或其他服务。重跑隔离配置/公钥实际读取检查后,只up router;重复执行不会覆盖备份或改密钥。
新prepare已包含此参数;build/activate的隔离容器现在会实际加载挂载的router公钥,不能只验证Settings字段就标记候选就绪。`state`不打印原始日志或环境,只报告原/候选镜像类别、容器状态/健康/退出码和固定错误类。已部分切换时rollback可识别停止或重启中的已知候选容器,但拒绝未知镜像;原有回滚限制仍适用。
### 完整回退
若切换失败,先停止broker客户端继续使用,按记录的每服务镜像回退:
```bash