feat: run a per-run OpenBao for failure checks, bench, CI and driver stands
Every stand with its own storages now brings up its own OpenBao and acts
as its operator: materials live in the run's temporary directory and are
removed on any outcome; the working stand's OpenBao is never touched.
- make failure_checks: own OpenBao, 20 s / 60 s token roles, six new
OpenBao fault checks, hook actions and the secrets log summary
- bao.py rewrite and waiting for the active node after unseal
- bench/: OpenBao in every fresh stand, "before" variants get secrets
via ${...} references, passport stand.secrets and limits.openbao
- CI job: BAO_ADDRESS, run OpenBao operator, override with openbao,
cleaner and migrate pairs, test_ci_override.py
- driver: shared temporary stand for freeze-lb and reconcile-signal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+65
-1
@@ -34,9 +34,15 @@ token и доли читаются в память, токен уходит то
|
||||
изменившиеся пути
|
||||
ready — подъём: ждать слушатель, init на пустом, код 2 на
|
||||
запечатанном, затем configure и seed
|
||||
rewrite — учения сверки версий (change openbao-tooling, design,
|
||||
решение 5): текущие данные пути из таблицы SEED — новой
|
||||
версией с теми же значениями; вывод — путь и версии N -> N+1
|
||||
без значений; данных пути в KV нет — код 1. Следующий seed
|
||||
версий не прибавляет (данные равны модели compose)
|
||||
|
||||
Коды: 0 — выполнено; 1 — отказ OpenBao или материалов; 2 — запечатан
|
||||
(`ready`), неверные аргументы или нет файлов.
|
||||
(`ready`), неверные аргументы (в том числе путь rewrite не из SEED) или нет
|
||||
файлов.
|
||||
"""
|
||||
|
||||
# аннотации — строками: синтаксис `X | None` и `dict[…]` системный python3 3.9
|
||||
@@ -74,6 +80,9 @@ SECRET_THRESHOLD = 3
|
||||
# прочие вызовы (unseal и запись — сотни мс)
|
||||
INIT_TIMEOUT_SECONDS = 120.0
|
||||
REQUEST_TIMEOUT_SECONDS = 30.0
|
||||
# секунды ожидания активного узла raft после unseal (на 0,25 CPU — доли
|
||||
# секунды, на шумном хосте — до нескольких)
|
||||
ACTIVE_TIMEOUT_SECONDS = 30.0
|
||||
|
||||
KV_MOUNT = "messenger"
|
||||
CERT_MOUNT = "cert"
|
||||
@@ -343,6 +352,30 @@ class Operator:
|
||||
) from None
|
||||
time.sleep(1)
|
||||
|
||||
def wait_active(self, timeout: float = ACTIVE_TIMEOUT_SECONDS) -> None:
|
||||
"""Ждать активного узла после unseal: raft сразу после распечатывания
|
||||
— standby только для чтения, и запись (а с ней аудит любого запроса,
|
||||
соль аудита) отвечает 500 «cannot write to readonly storage» (правка
|
||||
apply change openbao-tooling: так падал первый configure после init
|
||||
на стенде отказов). `sys/health`: 200 — активный, 429 — standby."""
|
||||
deadline = time.monotonic() + timeout
|
||||
while True:
|
||||
status, _ = self.http.request(
|
||||
"GET",
|
||||
"sys/health",
|
||||
ok=(200, 429, 472, 473, 501, 503),
|
||||
timeout=5,
|
||||
)
|
||||
if status == 200: # noqa: PLR2004
|
||||
return
|
||||
if time.monotonic() >= deadline:
|
||||
raise BaoError(
|
||||
f"OpenBao is not active in {timeout:.0f} s "
|
||||
f"(sys/health {status})",
|
||||
status=status,
|
||||
)
|
||||
time.sleep(0.5)
|
||||
|
||||
# команды ---------------------------------------------------------------
|
||||
|
||||
def status(self) -> int:
|
||||
@@ -556,6 +589,7 @@ class Operator:
|
||||
) from None
|
||||
if not result.get("sealed", True):
|
||||
log(f"unsealed OpenBao with {used} shares")
|
||||
self.wait_active()
|
||||
return 0
|
||||
raise BaoError("OpenBao is still sealed after all shares")
|
||||
|
||||
@@ -714,6 +748,7 @@ class Operator:
|
||||
raise BaoError("OpenBao is not initialized: run make bao_init")
|
||||
if state.get("sealed"):
|
||||
raise Sealed("OpenBao is sealed: run make bao_unseal")
|
||||
self.wait_active()
|
||||
|
||||
def seed(self) -> int:
|
||||
self._require_unsealed()
|
||||
@@ -781,6 +816,33 @@ class Operator:
|
||||
self.configure()
|
||||
return self.seed()
|
||||
|
||||
def rewrite(self) -> int:
|
||||
"""Те же данные пути — новой версией (значения не печатаются)."""
|
||||
self._require_unsealed()
|
||||
token = self.root_token()
|
||||
path = self.args.path
|
||||
status, current = self.http.request(
|
||||
"GET",
|
||||
kv_data_path(path),
|
||||
token=token,
|
||||
ok=(200, 404),
|
||||
)
|
||||
data = (current.get("data") or {}) if status == 200 else {}
|
||||
values = data.get("data")
|
||||
if not values:
|
||||
raise BaoError(f"kv {KV_MOUNT}/{path}: no data to rewrite")
|
||||
before = (data.get("metadata") or {}).get("version")
|
||||
_, written = self.http.request(
|
||||
"POST",
|
||||
kv_data_path(path),
|
||||
{"data": values},
|
||||
token=token,
|
||||
)
|
||||
del values, current, data
|
||||
after = (written.get("data") or {}).get("version")
|
||||
log(f"kv {KV_MOUNT}/{path}: version {before} -> {after}, rewritten")
|
||||
return 0
|
||||
|
||||
|
||||
def _same(current: object, desired: object) -> bool:
|
||||
if isinstance(desired, list):
|
||||
@@ -890,6 +952,8 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
"--compose-config",
|
||||
help="compose model JSON instead of docker compose config",
|
||||
)
|
||||
rewrite = commands.add_parser("rewrite")
|
||||
rewrite.add_argument("path", choices=sorted(SEED))
|
||||
return parser
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user