197 lines
10 KiB
Markdown
197 lines
10 KiB
Markdown
# 188 Host Hygiene 維護窗口 Runbook
|
||
|
||
> 版本:2026-07-11.v3
|
||
> 適用範圍:`192.168.0.188` host PostgreSQL `14/main`、`awoooi-startup.service`、certbot / ACME renewal hygiene。
|
||
> 狀態:`HOST_188_HYGIENE_GREEN`
|
||
|
||
---
|
||
|
||
## 1. 目的
|
||
|
||
188 目前的產品服務、public routes 與 host hygiene 均已收斂為 green。這份 runbook 將「服務恢復」、「host hygiene」、「DR escrow」與「Wazuh registry」分開,避免把 route `200`、container healthy、`pg_isready`、exporter green 或 `reset-failed` 誤判成其他層級也完成。
|
||
|
||
本文件記錄 2026-06-26 已完成的 188 host hygiene 修復與後續操作邊界。它不是 DR escrow 完成證明,也不是 Wazuh / SOC runtime action 授權。未取得 owner、rollback owner、maintenance window、backup / restore evidence 與 post-check plan 前,仍不得執行資料層 break-glass、restore、未批准 renew、或其他主機寫入。
|
||
|
||
---
|
||
|
||
## 2. 最新只讀證據
|
||
|
||
2026-07-11 14:55 Asia/Taipei live evidence 取代舊 2026-06-26 baseline:
|
||
|
||
| 層級 | 證據 | 判定 |
|
||
|------|------|------|
|
||
| Host systemd | `systemctl is-system-running` 為 `running`,failed units `0 loaded units listed` | host hygiene green |
|
||
| 產品容器 | MOMO、VibeWork、2026FIFA、ClawBot、MinIO、exporters、MOMO DB 等容器 healthy / up | 產品服務 green |
|
||
| PostgreSQL runtime | `k3s-postgres-recovery` container 為 `Running=true`、`NetworkMode=host`、restart policy `unless-stopped`,`pg_isready -h localhost -p 5432` accepting connections | production DB runtime green |
|
||
| Host PostgreSQL unit | `/etc/postgresql/14/main/start.conf=manual`,`postgresql@14-main.service` 為 disabled / inactive;recovery container 同一 data/config mount 仍 accepting connections | 避免 host/container 雙啟動競爭 |
|
||
| Startup unit | source/live SHA 為 `d9b099382fbc618280241d398a2a3d2c89f004804ab793c177a25a43505ebe8d`,unit SHA 為 `995705578f4ba50f02100f7f60f432fa86d3f37e13aaa6f1d93c1d8685a8cafb`;metadata repair、kine write、ClawBot rebuild、188 SignOz 均預設 opt-in | fail-closed 修復完成 |
|
||
| Nginx / ACME route | `sentry.wooo.work`、`gitea.wooo.work`、`langfuse.wooo.work`、`signoz.wooo.work` HTTP-01 self-test token 均由 `/var/www/html` 正確回應 | challenge route green |
|
||
| certbot timers | duplicate apt `certbot.timer` 已停用;snap `snap.certbot.renew.timer` enabled / active / waiting;`certbot.service` 與 `snap.certbot.renew.service` `Result=success / inactive` | renewal runner hygiene green |
|
||
| public cert | `sentry.wooo.work` certificate `notAfter=2026-09-24 13:44:28 UTC`,snap renew timer enabled / waiting | certificate readback green |
|
||
|
||
controlled reconcile receipt:`/usr/local/sbin/awoooi-host188-hygiene reconcile` 回 `PRODUCT_SERVICE_RESTARTS=0`,rollback 為 `/var/lib/awoooi-host188-hygiene/backups/host188-hygiene-20260711T145537+0800-334605-before-reconcile`。獨立 checklist 回 `PASS=17 WARN=1 BLOCKED=0`、`HOST_HYGIENE_BLOCKED=0`;warning 只說明 `pg_lsclusters` 看不到 container-owned PID model,不是 DB 不可用。
|
||
|
||
---
|
||
|
||
## 3. GO / NO-GO
|
||
|
||
| Gate | GO 條件 | NO-GO 條件 |
|
||
|------|---------|------------|
|
||
| 服務層 | MOMO / VibeWork / 2026FIFA / SignOz / public routes 可用 | 產品 route 或 DB 容器同時故障時,先走 incident triage |
|
||
| PostgreSQL | DB owner 確認 host `14/main` 是否仍為 authoritative source | 無法確認用途就不得 reset / disable / restore |
|
||
| Backup | 有可追溯 backup ref、restore target isolation、rollback owner | 沒有 backup / restore evidence 就不得 `pg_resetwal` 或 restore |
|
||
| certbot | DNS / ACME / public gateway owner response accepted,rate-limit 冷卻期明確 | ACME route 未確認、仍被 rate-limit、或缺 rollback owner |
|
||
| 維護窗口 | owner、窗口、post-check、operator notification 完整 | 只有「服務看起來綠」或「想清 failed units」 |
|
||
|
||
---
|
||
|
||
## 4. PostgreSQL `14/main` 決策樹
|
||
|
||
1. **先判定用途**
|
||
- 是否仍被任何 production service 使用。
|
||
- 是否只是舊的 host cluster,產品 DB 已由 containerized PostgreSQL 接管。
|
||
- 是否仍承載 K3s Kine、MOMO、monitoring、legacy app 或 operator tooling。
|
||
|
||
2. **若確認 host cluster 已廢棄**
|
||
- 準備 owner disposition:廢棄原因、affected scope、最後 backup / dump ref、保留期限。
|
||
- 維護窗口內才可停用 unit 或調整 startup script 的 host PG dependency。
|
||
- 停用後仍需 post-check:public routes、MOMO health、SignOz、exporters、backup-status、cold-start。
|
||
|
||
3. **若確認 host cluster 仍需要保留**
|
||
- 先建立隔離 restore target,不直接覆蓋 production data directory。
|
||
- 先比對 backup / WAL / data directory metadata。
|
||
- 只有 DB owner 明確接受資料風險與 rollback plan 後,才可進入 break-glass 修復。
|
||
|
||
4. **禁止預設路徑**
|
||
- 不得直接 `pg_resetwal`。
|
||
- 不得直接 `rm -rf /var/lib/postgresql/14/main`。
|
||
- 不得直接 `systemctl reset-failed` 假綠。
|
||
- 不得把 container `momo-db` healthy 當成 host `14/main` healthy。
|
||
|
||
---
|
||
|
||
## 5. certbot / ACME 決策樹
|
||
|
||
1. **先停止誤判**
|
||
- `certbot.service` failed 目前代表 renewal 未成功,不代表現有憑證立即失效。
|
||
- `sentry.wooo.work` cert 仍有效到 `2026-07-09 16:03:40 UTC`。
|
||
|
||
2. **先做 owner evidence**
|
||
- domain / SAN / shared certificate coverage ref。
|
||
- ACME challenge route owner。
|
||
- renewal owner。
|
||
- rollback owner。
|
||
- validation plan。
|
||
|
||
3. **維護窗口內才可做**
|
||
- `nginx -t`。
|
||
- ACME challenge route smoke。
|
||
- certbot dry-run 或 renew。
|
||
- Nginx reload。
|
||
|
||
4. **禁止事項**
|
||
- rate-limit 期間反覆 renew。
|
||
- 未確認 challenge route 就 renew。
|
||
- 同時保留 apt certbot timer 與 snap certbot timer 的重複失敗狀態。
|
||
- 貼出 private key、ACME account key、DNS credential、未脫敏 certbot log。
|
||
|
||
---
|
||
|
||
## 6. 維護窗口最小步驟
|
||
|
||
此段只定義順序;不代表目前已批准執行。
|
||
|
||
### Phase 0:一鍵只讀 preflight
|
||
|
||
在 repo 工作站先執行只讀 checklist;它不會 restart、reload、renew、reset-failed、restore、`pg_resetwal` 或寫入遠端狀態。
|
||
|
||
```bash
|
||
SSH_BATCH_MODE=yes bash scripts/reboot-recovery/188-host-hygiene-maintenance-checklist.sh --no-color
|
||
```
|
||
|
||
目前預期結果是:
|
||
|
||
```text
|
||
SERVICE_GREEN=1
|
||
HOST_HYGIENE_BLOCKED=0
|
||
RUNTIME_ACTION_AUTHORIZED=0
|
||
Result: HOST_188_HYGIENE_GREEN.
|
||
```
|
||
|
||
### Phase A:維護前只讀快照
|
||
|
||
```bash
|
||
systemctl --failed --no-pager
|
||
pg_lsclusters
|
||
systemctl status postgresql@14-main.service --no-pager
|
||
systemctl status certbot.service snap.certbot.renew.service --no-pager
|
||
docker ps --format '{{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||
/backup/scripts/backup-status.sh --no-notify
|
||
/home/wooo/scripts/full-stack-cold-start-check.sh --monitor-read-only --no-color --watch --interval 1 --max-attempts 1
|
||
```
|
||
|
||
### Phase B:owner 決策
|
||
|
||
| 決策 | 必填 evidence |
|
||
|------|---------------|
|
||
| host PostgreSQL 廢棄 | owner disposition、affected services、last backup ref、retention owner |
|
||
| host PostgreSQL restore | source backup ref、isolated restore target、checksum / row-count plan、rollback owner |
|
||
| certbot route 修復 | certificate coverage ref、ACME owner、challenge route plan、post-renew validation |
|
||
|
||
### Phase C:受控修復
|
||
|
||
先安裝固定動作 executor,再分開執行 check / reconcile:
|
||
|
||
```bash
|
||
scripts/reboot-recovery/bootstrap-host188-hygiene-executor.sh --check
|
||
scripts/reboot-recovery/bootstrap-host188-hygiene-executor.sh --apply
|
||
ssh ollama@192.168.0.188 'sudo -n /usr/local/sbin/awoooi-host188-hygiene check'
|
||
ssh ollama@192.168.0.188 'sudo -n /usr/local/sbin/awoooi-host188-hygiene reconcile'
|
||
```
|
||
|
||
executor 只能安裝 canonical startup source/unit、將 PG start mode 設為 manual、daemon-reload 與 reset stale failed state;不能 start/restart/stop 產品、Docker、Nginx 或 PostgreSQL。回滾只允許 `sudo -n /usr/local/sbin/awoooi-host188-hygiene rollback-latest`。
|
||
|
||
### Phase D:post-check
|
||
|
||
```bash
|
||
systemctl --failed --no-pager
|
||
pg_lsclusters
|
||
curl -fsS https://mo.wooo.work/health
|
||
curl -fsS https://stock.wooo.work/api/v1/system/freshness
|
||
curl -fsS https://awoooi.wooo.work/api/v1/health
|
||
/backup/scripts/backup-status.sh --no-notify --no-refresh
|
||
/home/wooo/scripts/full-stack-cold-start-check.sh --monitor-read-only --no-color --watch --interval 1 --max-attempts 1
|
||
```
|
||
|
||
成功標準:
|
||
|
||
- 產品 routes 仍綠。
|
||
- backup core 仍 `core_blockers=0`。
|
||
- cold-start 維持 `WARN=0 BLOCKED=0`。
|
||
- 若 owner 決定 host PG 廢棄,systemd failed unit 必須以 owner disposition 收斂,不可只是 reset-failed。
|
||
- 若 owner 決定 host PG 修復,必須有 restore / data integrity evidence。
|
||
- 若 certbot 修復,必須有 cert notAfter、ACME route、Nginx config test 與 reload evidence。
|
||
|
||
---
|
||
|
||
## 7. 目前完成度
|
||
|
||
| Lane | 完成度 | 說明 |
|
||
|------|-------:|------|
|
||
| 服務恢復 | `100%` | routes、containers、cold-start、backup core 已 green |
|
||
| 188 host hygiene repair | `100%` | startup fail-closed、PostgreSQL runtime-ready 判斷、systemd failed units、ACME route 與 certbot timer hygiene 已收斂 |
|
||
| PostgreSQL runtime source-of-truth | `100%` | production DB runtime 以 `k3s-postgres-recovery` host-network container + `pg_isready` 判斷,不用 host `pg_lsclusters` 假紅 |
|
||
| certbot / ACME route hygiene | `100%` | snap renew timer active,certificate 有效到 2026-09-24;續依正常 timer 監控 |
|
||
| DR escrow | `100%` | 2026-07-11 checklist 回 `escrow_missing=0`,但仍與 host hygiene 分開記錄 |
|
||
| Wazuh registry | `NOT_EVALUATED_THIS_RUN` | 本輪 188 checklist 未取得 fresh manager registry acceptance,不得沿用舊值作目前結論 |
|
||
|
||
---
|
||
|
||
## 8. 不得宣稱
|
||
|
||
- 不得用 188 host green 單獨宣稱全平台 DR complete;DR 必須讀同一輪 backup/escrow scorecard。
|
||
- 不得宣稱 Wazuh registry recovered;本輪沒有 fresh manager registry acceptance readback。
|
||
- 不得因 certificate 目前有效就停用 snap renew timer / expiry 告警。
|
||
- 不得把 `reset-failed` 單獨當成修復完成;本次完成是因 startup source、Nginx ACME route、timer split 與 postcheck 同時收斂。
|
||
- 不得宣稱這份文件批准任何新的 runtime action。
|