lab4: память загрузок и S3 под лимитом, документация защиты

- тело загрузки: один буфер ровно Content-Length, без копий до S3 и djpeg;
- PNG: zlib получает вход кусками по 64 KiB (unconsumed_tail копировал остаток IDAT);
- djpeg, убитый OOM-killer'ом, -> 503 (ресурсы сервера), а не 415;
- api: memswap_limit = memory (жёсткий лимит без swap); S3: GOMEMLIMIT и лимиты
  одновременных загрузок SeaweedFS, память 1g;
- docs: CONSISTENCY.md, DEFENSE.md, WINDOWS.md, DATA_MODEL.md под lab4;
  scripts/demo_attachments.py для сценария защиты; CI и collect_evidence под lab4;
- bench/reconcile_faults.py: отчёты трека 2 (ошибки с обеих сторон, прерванный apply).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alexey Bodanyuk
2026-10-25 14:21:43 +03:00
co-authored by Claude Opus 5.5
parent a2d867bec6
commit 4ea6924db1
18 changed files with 701 additions and 120 deletions
+93
View File
@@ -0,0 +1,93 @@
# 2026-10-25T11:06:22Z commit a2d867b
## round 1
$ python scripts/lbctl.py replicas
mtusi-lab4-api-1 X-Instance-Id=05c02ec0a89f running health=healthy pid=33267 started=2026-10-25T11:05:59.978 ip=172.25.0.3,172.26.0.4,172.27.0.2
mtusi-lab4-api-2 X-Instance-Id=4ddc189deda2 running health=healthy pid=33344 started=2026-10-25T11:06:00.330 ip=172.25.0.4,172.26.0.5,172.27.0.3
$ python tests/resilience.py --mode failover --action-script scripts/stop-one.cmd
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 133, "failed_attempts": 0, "first_recovery_seconds": 6.008}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0
$ python scripts/lbctl.py replicas (after hook)
mtusi-lab4-api-1 X-Instance-Id=05c02ec0a89f exited health=unhealthy pid=0 started=2026-10-25T11:05:59.978 ip=-
mtusi-lab4-api-2 X-Instance-Id=4ddc189deda2 running health=healthy pid=33344 started=2026-10-25T11:06:00.330 ip=172.25.0.4,172.26.0.5,172.27.0.3
$ sh scripts/restore-api.sh && python scripts/lbctl.py wait-up 2
mtusi-lab4-api-1 Up 6 seconds (healthy)
mtusi-lab4-api-2 Up 46 seconds (healthy)
2 API replica(s) UP in HAProxy after 0.6 s: ['05c02ec0a89f', '4ddc189deda2']
## round 2
$ python scripts/lbctl.py replicas
mtusi-lab4-api-1 X-Instance-Id=05c02ec0a89f running health=healthy pid=35395 started=2026-10-25T11:06:40.508 ip=172.25.0.3,172.26.0.4,172.27.0.2
mtusi-lab4-api-2 X-Instance-Id=4ddc189deda2 running health=healthy pid=33344 started=2026-10-25T11:06:00.330 ip=172.25.0.4,172.26.0.5,172.27.0.3
$ python tests/resilience.py --mode failover --action-script scripts/stop-one.cmd
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 132, "failed_attempts": 0, "first_recovery_seconds": 5.738}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0
$ python scripts/lbctl.py replicas (after hook)
mtusi-lab4-api-1 X-Instance-Id=05c02ec0a89f exited health=unhealthy pid=0 started=2026-10-25T11:06:40.508 ip=-
mtusi-lab4-api-2 X-Instance-Id=4ddc189deda2 running health=healthy pid=33344 started=2026-10-25T11:06:00.330 ip=172.25.0.4,172.26.0.5,172.27.0.3
$ sh scripts/restore-api.sh && python scripts/lbctl.py wait-up 2
mtusi-lab4-api-1 Up 6 seconds (healthy)
mtusi-lab4-api-2 Up About a minute (healthy)
2 API replica(s) UP in HAProxy after 0.6 s: ['05c02ec0a89f', '4ddc189deda2']
## round 3
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 133, "failed_attempts": 0, "first_recovery_seconds": 5.931}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0
$ python scripts/lbctl.py replicas (after hook)
mtusi-lab4-api-1 X-Instance-Id=05c02ec0a89f exited health=unhealthy pid=0 started=2026-10-25T11:07:06.512 ip=-
mtusi-lab4-api-2 X-Instance-Id=4ddc189deda2 running health=healthy pid=33344 started=2026-10-25T11:06:00.330 ip=172.25.0.4,172.26.0.5,172.27.0.3
$ sh scripts/restore-api.sh && python scripts/lbctl.py wait-up 2
mtusi-lab4-api-1 Up 6 seconds (healthy)
mtusi-lab4-api-2 Up About a minute (healthy)
2 API replica(s) UP in HAProxy after 0.7 s: ['05c02ec0a89f', '4ddc189deda2']
## round 4
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 133, "failed_attempts": 0, "first_recovery_seconds": 6.053}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0
$ python scripts/lbctl.py replicas (after hook)
mtusi-lab4-api-1 X-Instance-Id=05c02ec0a89f exited health=unhealthy pid=0 started=2026-10-25T11:07:44.818 ip=-
mtusi-lab4-api-2 X-Instance-Id=4ddc189deda2 running health=healthy pid=33344 started=2026-10-25T11:06:00.330 ip=172.25.0.4,172.26.0.5,172.27.0.3
$ sh scripts/restore-api.sh && python scripts/lbctl.py wait-up 2
mtusi-lab4-api-1 Up 6 seconds (healthy)
mtusi-lab4-api-2 Up 2 minutes (healthy)
2 API replica(s) UP in HAProxy after 0.7 s: ['05c02ec0a89f', '4ddc189deda2']
## round 5
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 133, "failed_attempts": 0, "first_recovery_seconds": 5.809}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0
$ python scripts/lbctl.py replicas (after hook)
mtusi-lab4-api-1 X-Instance-Id=05c02ec0a89f exited health=unhealthy pid=0 started=2026-10-25T11:08:10.900 ip=-
mtusi-lab4-api-2 X-Instance-Id=4ddc189deda2 running health=healthy pid=33344 started=2026-10-25T11:06:00.330 ip=172.25.0.4,172.26.0.5,172.27.0.3
$ sh scripts/restore-api.sh && python scripts/lbctl.py wait-up 2
mtusi-lab4-api-1 Up 6 seconds (healthy)
mtusi-lab4-api-2 Up 2 minutes (healthy)
2 API replica(s) UP in HAProxy after 0.6 s: ['05c02ec0a89f', '4ddc189deda2']
## round 6
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 133, "failed_attempts": 0, "first_recovery_seconds": 5.952}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0
$ python scripts/lbctl.py replicas (after hook)
mtusi-lab4-api-1 X-Instance-Id=05c02ec0a89f exited health=unhealthy pid=0 started=2026-10-25T11:08:37.062 ip=-
mtusi-lab4-api-2 X-Instance-Id=4ddc189deda2 running health=healthy pid=33344 started=2026-10-25T11:06:00.330 ip=172.25.0.4,172.26.0.5,172.27.0.3
$ sh scripts/restore-api.sh && python scripts/lbctl.py wait-up 2
mtusi-lab4-api-1 Up 6 seconds (healthy)
mtusi-lab4-api-2 Up 3 minutes (healthy)
2 API replica(s) UP in HAProxy after 0.7 s: ['05c02ec0a89f', '4ddc189deda2']
## round 7 (one extra GET /health/live first: shifts HAProxy round-robin so the OTHER replica serves the test's first message)
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 133, "failed_attempts": 0, "first_recovery_seconds": 6.146}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0
$ python scripts/lbctl.py replicas (after hook)
mtusi-lab4-api-1 X-Instance-Id=05c02ec0a89f running health=healthy pid=42280 started=2026-10-25T11:09:03.178 ip=172.25.0.3,172.26.0.4,172.27.0.2
mtusi-lab4-api-2 X-Instance-Id=4ddc189deda2 exited health=unhealthy pid=0 started=2026-10-25T11:06:00.330 ip=-
$ sh scripts/restore-api.sh && python scripts/lbctl.py wait-up 2
mtusi-lab4-api-1 Up 42 seconds (healthy)
mtusi-lab4-api-2 Up 6 seconds (healthy)
2 API replica(s) UP in HAProxy after 0.6 s: ['05c02ec0a89f', '4ddc189deda2']
+19
View File
@@ -0,0 +1,19 @@
# 2026-10-25T11:05:12Z commit a2d867b
$ docker compose ps (before)
mtusi-lab4-api-1 Up 15 minutes (healthy)
mtusi-lab4-api-2 Up 15 minutes (healthy)
mtusi-lab4-lb-1 Up 21 minutes (healthy)
mtusi-lab4-postgres-1 Up 2 minutes (healthy)
mtusi-lab4-s3-1 Up 2 minutes (healthy)
mtusi-lab4-valkey-1 Up 21 minutes (healthy)
$ python tests/resilience.py --mode persistence --action-script scripts/restart.cmd
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
exit=0
$ docker compose ps (after: StartedAt of every container)
/mtusi-lab4-api-1 started=2026-10-25T11:05:59.978502661Z restarts=0
/mtusi-lab4-api-2 started=2026-10-25T11:06:00.330525085Z restarts=0
/mtusi-lab4-lb-1 started=2026-10-25T11:06:09.717330457Z restarts=0
/mtusi-lab4-postgres-1 started=2026-10-25T11:05:20.208770445Z restarts=0
/mtusi-lab4-s3-1 started=2026-10-25T11:05:40.143650484Z restarts=0
/mtusi-lab4-valkey-1 started=2026-10-25T11:05:20.150545076Z restarts=0