Files
mtusi2026lab3/evidence/failover/stop-one-refusals.md
T
ricoromaandClaude Opus 5.5 cb14586a19 docs: retake replicas-lb evidence from a4ca9ef after verify
The stand was recreated from a4ca9ef (make down, make run_docker) and
all evidence of the change was taken again on it: stand, distribution,
LB errors, test-persistence, test-failover for each replica (stop and
kill), stop-one refusals, make test and student_test through the LB,
test_isolated, failure_checks and bench self-checks.

New evidence closes scenarios verify found without proof: a real git
clone on non-default ports, a hung replica (docker pause: DOWN after
7.7 s, in-flight request 504), PostgreSQL outage behind the LB, replica
tests failing against one process, aborted responses via
driver.py kill-inflight. REPORT.md gets the corrected detection
formula, the measured cost of the 1 CPU limit for Argon2id and the new
rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 22:09:15 +03:00

5.1 KiB

scripts/stop-one.sh: отказ на чужой или неверный TARGET_INSTANCE_ID

Спеки load-balancing «Failover hook» — «Чужой или неизвестный id»
Change replicas-lb, задачи 6.1 и 7.2 (пустое значение — код 2 явно, исправлено в verify)
Дата 2026-10-10 15:50:20 UTC
Commit a4ca9ef (стенд пересоздан с этого commit, ../replicas/stand.md)
Стенд make run_docker: проект mtusi-lab3, HAProxy на 127.0.0.1:8080, api × 2 (восстановлены make replicas после test-failover-kill.md)
Хост Docker Desktop 29.8.1, macOS arm64; ВМ Docker: 12 CPU, 7,7 GiB RAM; ноутбук от батареи

Скрипт проверяет значение (непустое, hex, 12–64 символа) до вызова docker — код 2, и ищет ID префиксом только среди работающих реплик api этого проекта (docker compose ps -q api) — код 3, если не нашёл. Postgres, Valkey, LB, migrate и контейнеры других проектов в этот список не входят.

$ ps (до)
api /mtusi-lab3-api-1 3681880fc55f running exit=0 started=2026-10-10T15:50:16.991427337Z
api /mtusi-lab3-api-2 8100f940a5fa running exit=0 started=2026-10-10T15:48:33.765274636Z
haproxy /mtusi-lab3-haproxy-1 f878fd1fbf83 running exit=0 started=2026-10-10T15:47:58.560031592Z
migrate /mtusi-lab3-migrate-1 ffd98512d938 exited exit=0 started=2026-10-10T15:47:56.875245466Z
postgres /mtusi-lab3-postgres-1 da3195a39fcf running exit=0 started=2026-10-10T15:47:55.066928966Z
valkey /mtusi-lab3-valkey-1 169515bef463 running exit=0 started=2026-10-10T15:47:55.039021882Z

$ unset TARGET_INSTANCE_ID; scripts/stop-one.sh
stop-one: TARGET_INSTANCE_ID is empty; test provides target API instance alias
exit=2
$ TARGET_INSTANCE_ID= scripts/stop-one.sh
stop-one: TARGET_INSTANCE_ID is empty; test provides target API instance alias
exit=2
$ TARGET_INSTANCE_ID=API-1 scripts/stop-one.sh
stop-one: TARGET_INSTANCE_ID is not a container id
exit=2
$ TARGET_INSTANCE_ID=zz12345678901 scripts/stop-one.sh
stop-one: TARGET_INSTANCE_ID is not a container id
exit=2
$ TARGET_INSTANCE_ID=abc123 scripts/stop-one.sh    # короче 12 символов
stop-one: TARGET_INSTANCE_ID is not a container id
exit=2
$ TARGET_INSTANCE_ID=da3195a39fcf scripts/stop-one.sh    # postgres этого стенда
stop-one: no running api replica of this project matches TARGET_INSTANCE_ID
exit=3
$ TARGET_INSTANCE_ID=169515bef463 scripts/stop-one.sh    # valkey
stop-one: no running api replica of this project matches TARGET_INSTANCE_ID
exit=3
$ TARGET_INSTANCE_ID=f878fd1fbf83 scripts/stop-one.sh    # haproxy
stop-one: no running api replica of this project matches TARGET_INSTANCE_ID
exit=3
$ TARGET_INSTANCE_ID=ffd98512d938 scripts/stop-one.sh    # migrate
stop-one: no running api replica of this project matches TARGET_INSTANCE_ID
exit=3
$ TARGET_INSTANCE_ID=0123456789ab scripts/stop-one.sh    # несуществующий
stop-one: no running api replica of this project matches TARGET_INSTANCE_ID
exit=3
$ TARGET_INSTANCE_ID=3681880fc55f STOP_MODE=pause scripts/stop-one.sh
stop-one: STOP_MODE must be stop or kill
exit=2

$ ps (после)
api /mtusi-lab3-api-1 3681880fc55f running exit=0 started=2026-10-10T15:50:16.991427337Z
api /mtusi-lab3-api-2 8100f940a5fa running exit=0 started=2026-10-10T15:48:33.765274636Z
haproxy /mtusi-lab3-haproxy-1 f878fd1fbf83 running exit=0 started=2026-10-10T15:47:58.560031592Z
migrate /mtusi-lab3-migrate-1 ffd98512d938 exited exit=0 started=2026-10-10T15:47:56.875245466Z
postgres /mtusi-lab3-postgres-1 da3195a39fcf running exit=0 started=2026-10-10T15:47:55.066928966Z
valkey /mtusi-lab3-valkey-1 169515bef463 running exit=0 started=2026-10-10T15:47:55.039021882Z

# сразу после — ID контейнера другого проекта
$ TARGET_INSTANCE_ID=e352c514d163 scripts/stop-one.sh    # api проекта mtusi-lab2
stop-one: no running api replica of this project matches TARGET_INSTANCE_ID
exit=3
$ docker inspect -f '{{.Name}} {{.State.Status}} {{.State.FinishedAt}}' e352c514d163
/mtusi-lab2-api-1 exited 2026-10-02T18:56:42.98517984Z

Все отказы — с ненулевым кодом: 2 — неверное значение или режим (до вызова docker), 3 — нет такой работающей реплики. StartedAt и состояние каждого контейнера стенда до и после совпадают. Контейнер второй лабы (mtusi-lab2-api-1, остановлен 2026-10-02) скрипт тоже не трогает: его нет в docker compose ps -q api этого проекта.

До verify пустое значение давало код 1: проверка шла через ${VAR:?} образца, а он даёт 1 в bash и 2 в dash. Теперь проверка явная, код 2 в любой оболочке, как в design (решение 7).