feat: add job outbox, relay, leases and image variants to the pipeline

Move publishing out of the upload path: a relay process publishes queued
jobs with confirms. Add lease and attempt fencing, backoff with jitter, a
per-job render process with CPU and memory limits, crop and optimized
variants, the failed registry with audited replay, and staging cleanup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 15:36:15 +03:00
co-authored by Claude Opus 5.5
parent 99a222eee2
commit e2a6427c24
102 changed files with 9499 additions and 1916 deletions
+5 -4
View File
@@ -101,11 +101,12 @@ backend api
# загрузки:
# до тела — 2 × [database] request_timeout_seconds (вход, членство) +
# [uploads] wait_timeout_seconds = 2 × 6 + 5 = 17 с;
# после тела — проверка (до ~4 с) + pending 6 + PUT 5 + queued 6 +
# публикация 2 + отметка или отмена 6 ≈ 29 с; ветка компенсации после
# неудачной фиксации queued — компенсация 5 вместо публикации, 26 с.
# после тела — проверка (до ~4 с) + pending 6 + PUT 5 + queued 6 = 21 с,
# а ветка компенсации после неудачной фиксации queued — ещё DELETE 5,
# 26 с: брокера в пути нет (design change pipeline-reliability, решение
# 11).
# Тело ограничивают [uploads] body_timeout_seconds (30 с) и timeout
# client; наибольшая длительность загрузки 17 + 30 + 29 ≈ 76 с <
# client; наибольшая длительность загрузки 17 + 30 + 26 ≈ 73 с <
# ROLLOUT_DRAIN_TIMEOUT (90 с, scripts/rolling-update.sh). Остальные
# пути — прежние 10 с. Выражение — путь ручки в API
# (src/api/routers/v1/attachment.py): при смене префикса менять вместе
+14
View File
@@ -0,0 +1,14 @@
# Откат реплик на образ до change `pipeline-reliability` (design, Migration Plan):
# прежний код публикует задание сам, и без адреса и пароля брокера его загрузка — 503.
#
# make rolling_update COMMIT=7f38948 MIGRATE=0 \
# COMPOSE_FILE=docker-compose.yml:infra/rollback/broker.compose.yml
#
# Только на время отката: у реплик этого кода пароля брокера быть не должно.
services:
api:
environment:
BROKER__HOST: ${RABBITMQ_HOST:-rabbitmq}
BROKER__PORT: ${RABBITMQ_PORT:-5672}
BROKER__USER: ${RABBITMQ_DEFAULT_USER:?RABBITMQ_DEFAULT_USER is not set, run make env_setup}
BROKER__PASSWORD: ${RABBITMQ_DEFAULT_PASS:?RABBITMQ_DEFAULT_PASS is empty, run make env_setup}
+15 -3
View File
@@ -271,7 +271,13 @@ check_list_prefix() {
# уборщику — чтение и удаление объектов своего bucket и их список только с
# префиксом вложений своей базы (условие s3:prefix соблюдает SeaweedFS 4.48:
# весь bucket, другой префикс и HEAD bucket — 403); без записи и прав на
# bucket (design change track2-reconciler, решение 2)
# bucket (design change track2-reconciler, решение 2). С change
# pipeline-reliability (решение 9) — ещё префикс staging той же базы: выводится
# из уже проверенного имени
staging_list_prefix() {
printf '%s/staging/' "${LIST_PREFIX%/attachments/}"
}
put_cleaner_policy() {
cat >"$WORK/policy.json" <<EOF
{"Version": "2012-10-17", "Statement": [{"Effect": "Allow",
@@ -279,7 +285,7 @@ put_cleaner_policy() {
"Resource": ["arn:aws:s3:::${BUCKET}/*"]},
{"Effect": "Allow", "Action": ["s3:ListBucket"],
"Resource": ["arn:aws:s3:::${BUCKET}"],
"Condition": {"StringLike": {"s3:prefix": ["${LIST_PREFIX}*"]}}}]}
"Condition": {"StringLike": {"s3:prefix": ["${LIST_PREFIX}*", "$(staging_list_prefix)*"]}}}]}
EOF
ws_step "policy put ${CLEANER_POLICY}" \
"s3.policy -put -name=${CLEANER_POLICY} -file=$WORK/policy.json"
@@ -384,6 +390,8 @@ apply_checks() {
# список своего префикса: политика доходит до шлюза подпиской, как ключ
wait_key 200 "$CLEANER_CRED" "$(list_url "$LIST_PREFIX")" \
|| fail "cleaner key list ${LIST_PREFIX} (code ${code})"
wait_key 200 "$CLEANER_CRED" "$(list_url "$(staging_list_prefix)")" \
|| fail "cleaner key list $(staging_list_prefix) (code ${code})"
[ "$(cleaner_signed -X DELETE "$probe")" = 204 ] || fail "cleaner key delete"
[ "$(signed "$probe")" = 404 ] || fail "object is still there after delete"
worker_probe="${S3}/${BUCKET}/.s3-bootstrap/worker-check-$$"
@@ -406,7 +414,7 @@ apply_checks() {
[ "$(signed -X DELETE "$worker_probe")" = 204 ] \
|| fail "api key delete worker probe"
say "checks passed (api key put/get; cleaner key get/delete and list" \
"${LIST_PREFIX}; worker key put/get; api key list and bucket create," \
"${LIST_PREFIX} and $(staging_list_prefix); worker key put/get; api key list and bucket create," \
"cleaner key put and list of the bucket, worker key delete, list and" \
"bucket create, anonymous get and list denied)"
}
@@ -467,6 +475,10 @@ run_checks() {
"$(cleaner_signed "${S3}/${BUCKET}?list-type=2")"
check "cleaner key list attachments prefix" 200 \
"$(cleaner_signed "$(list_url "$LIST_PREFIX")")"
check "cleaner key list staging prefix" 200 \
"$(cleaner_signed "$(list_url "$(staging_list_prefix)")")"
check "cleaner key list database prefix" 403 \
"$(cleaner_signed "$(list_url "${LIST_PREFIX%attachments/}")")"
check "cleaner key list other prefix" 403 \
"$(cleaner_signed "$(list_url .s3-check/)")"
check "cleaner key create bucket" 403 \