feat: separate PostgreSQL roles and Valkey ACL per service

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 14:10:09 +03:00
co-authored by Claude Opus 5.5
parent c5b03e6efa
commit d5eaeb3183
44 changed files with 4013 additions and 129 deletions
+23 -4
View File
@@ -88,6 +88,9 @@ CRASH_LINES_MAX = 20
# отказ pg_hba.conf стенда соединению без TLS (change storage-tls): в журнале
# прогона его быть не должно — healthcheck и пробы hook ходят по TLS
PLAINTEXT_REFUSAL = "no encryption"
# отказ в правах роли процесса (change storage-roles): процессы стенда работают
# ролями по матрице, такой строки в журнале прогона быть не должно
PERMISSION_DENIED = "permission denied"
# «тесный» API: короткие сроки сессии и ключа идемпотентности, пул из
# одного соединения
TIGHT_ENV = {
@@ -395,16 +398,21 @@ def postgres_log_check(project: str) -> int:
# отказы соединений без TLS (change storage-tls): healthcheck, пробы hook и
# процессы стенда ходят по TLS — такой строки быть не должно
plaintext = [line for line in lines if PLAINTEXT_REFUSAL in line]
# отказ в правах роли процесса (change storage-roles, design, решение 10):
# процессы стенда работают ролями по матрице — недостающее право задетого
# пути видно здесь, даже если тест его не заметил
denied = [line for line in lines if PERMISSION_DENIED in line.lower()]
say(
f"postgres log: {len(lines)} lines, crash markers {len(crashes)}; "
f'"too many clients" {too_many}, "administrator command" {admin}, '
f'"{PLAINTEXT_REFUSAL}" {len(plaintext)}',
f'"{PLAINTEXT_REFUSAL}" {len(plaintext)}, '
f'"{PERMISSION_DENIED}" {len(denied)}',
)
if not crashes and not plaintext:
if not crashes and not plaintext and not denied:
return 0
if crashes:
say("crash markers in the postgres log:")
for line in (crashes + plaintext)[:CRASH_LINES_MAX]:
for line in (crashes + plaintext + denied)[:CRASH_LINES_MAX]:
print(line, flush=True)
return 1
@@ -518,8 +526,19 @@ def run_stand(
"s3",
"rabbitmq",
)
# роли процессов и владелец схемы — до миграций (change storage-roles,
# design, решение 10): код bootstrap — отдельным up, как s3-bootstrap
say("database roles bootstrap")
dc(
project,
"up",
"--no-deps",
"--exit-code-from",
"postgres-bootstrap",
"postgres-bootstrap",
)
say("migrations")
dc(project, "run", "--rm", "migrate")
dc(project, "run", "--rm", "--no-deps", "migrate")
# --wait одноразовый сервис считает готовым уже запущенным: код
# выхода bootstrap — отдельным up, как make start_s3
say("s3 bootstrap")