fix: address openbao-secrets verify findings

bao_check now compares cert auth roles and policies in OpenBao with
the repository and tries every foreign identity against every role
and without a role name; API and migrations exit with code 2 on
invalid settings; stop-at-start runs its attempts next to the stand's
OpenBao again; openbao-outage checks the exit code, the record and
the restart; run_docker restarts only services started before seed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 15:17:57 +03:00
co-authored by Claude Opus 5.5
parent 3875db4007
commit 4dd73299cf
16 changed files with 699 additions and 83 deletions
+14 -1
View File
@@ -13,7 +13,20 @@ if __name__ == "__main__":
# кэш процесса), и нечитаемый CA ронял процесс traceback с кодом 1 до
# проверки. Логгер ещё не настроен — запись мимо structlog, как у
# worker и уборщика; поля без значений и путей, код 2
from src.config import settings
from pydantic import ValidationError
try:
from src.config import settings
except ValidationError as e:
# неверные настройки (в том числе http-адрес OpenBao): логгер их тоже
# читает и не настроен. Запись без значений полей и код 2, как у
# worker, relay и уборщика (change openbao-secrets, правки verify W2)
early_stop.write_settings_error(
"Invalid API settings",
module="startup",
error=e,
)
sys.exit(2)
from src.infra.tls.client import API_STORAGES, client_tls_problems
if problems := client_tls_problems(settings, API_STORAGES):
+19
View File
@@ -66,6 +66,25 @@ def write_record(event: str, *, level: str, **fields: object) -> None:
os.write(1, (json.dumps(record) + "\n").encode())
def write_settings_error(event: str, *, module: str, error: object) -> None:
"""Запись о неверных настройках (`pydantic.ValidationError` — по
утиной типизации, модуль только stdlib): `loc` и `msg` ошибок без
значений полей — в них могут быть секреты (change `openbao-secrets`,
правки verify W2: API и миграции, как worker)."""
write_record(
event,
level="error",
module=module,
errors=[
{
"loc": ".".join(str(part) for part in item["loc"]),
"msg": item["msg"],
}
for item in error.errors(include_input=False) # type: ignore[attr-defined]
],
)
def _stop(signum: int, _frame: FrameType | None) -> None:
if not _armed:
return