forked from mtusi2026/mtusi2026lab4
89 lines
4.5 KiB
Plaintext
89 lines
4.5 KiB
Plaintext
# S3: идемпотентный bootstrap, приватность мимо API, отказ S3, сверка
|
||
# date: 2026-11-05T14:00:11Z
|
||
# commit: f8e41b1
|
||
|
||
## Повторный bootstrap ничего не ломает
|
||
$ docker compose run --rm --no-deps -T s3-init
|
||
Bucket created successfully `root/messenger-attachments`.
|
||
Access permission for `root/messenger-attachments` is set to `private`
|
||
Created policy `messenger-api` successfully.
|
||
bucket messenger-attachments ready
|
||
|
||
$ docker compose run --rm --no-deps -T s3-init
|
||
Bucket created successfully `root/messenger-attachments`.
|
||
Access permission for `root/messenger-attachments` is set to `private`
|
||
Created policy `messenger-api` successfully.
|
||
bucket messenger-attachments ready
|
||
|
||
$ sh scripts/check-s3.sh
|
||
## S3 не опубликован наружу, консоль выключена
|
||
s3 ports=9000/tcp
|
||
MINIO_BROWSER=off
|
||
|
||
## Права пользователя API: только свой bucket
|
||
PUT в свой bucket -> allowed
|
||
GET из своего bucket -> allowed
|
||
создание другого bucket -> denied
|
||
GET из другого bucket -> denied
|
||
PUT в другой bucket -> denied
|
||
изменение политики bucket -> denied
|
||
администрирование пользователей -> denied
|
||
|
||
## Анонимный доступ напрямую к S3, мимо API
|
||
GET messenger-attachments/<object> -> 403
|
||
GET messenger-attachments/ -> 403
|
||
PUT messenger-attachments/anon.txt -> 403
|
||
|
||
PASS: bucket приватный, у API нет прав вне своего bucket
|
||
|
||
## Отказ: контейнер S3 остановлен
|
||
$ sh scripts/s3-outage.sh stop
|
||
## S3: stop
|
||
GET /health/live -> 200 0.01s X-Instance-Id=yes
|
||
GET /health/ready -> 503 unavailable 1.01s X-Instance-Id=yes
|
||
GET /attachments/{id} -> 200 0.01s X-Instance-Id=yes
|
||
GET /attachments/{id}/content -> 503 unavailable 1.01s X-Instance-Id=yes
|
||
POST /attachments -> 503 unavailable 1.03s X-Instance-Id=yes
|
||
POST /messages (текст) -> 201 0.03s X-Instance-Id=yes
|
||
## S3 восстановлен
|
||
GET /health/ready -> 200 0.01s X-Instance-Id=yes
|
||
GET /attachments/{id}/content -> 200 0.01s X-Instance-Id=yes
|
||
sha256 совпадает: True
|
||
|
||
## Отказ: контейнер S3 завис (docker pause)
|
||
$ sh scripts/s3-outage.sh pause
|
||
## S3: pause
|
||
GET /health/live -> 200 0.01s X-Instance-Id=yes
|
||
GET /health/ready -> 503 unavailable 1.01s X-Instance-Id=yes
|
||
GET /attachments/{id} -> 200 0.01s X-Instance-Id=yes
|
||
GET /attachments/{id}/content -> 503 unavailable 5.01s X-Instance-Id=yes
|
||
POST /attachments -> 503 unavailable 5.02s X-Instance-Id=yes
|
||
POST /messages (текст) -> 201 0.01s X-Instance-Id=yes
|
||
## S3 восстановлен
|
||
GET /health/ready -> 200 0.01s X-Instance-Id=yes
|
||
GET /attachments/{id}/content -> 200 0.01s X-Instance-Id=yes
|
||
sha256 совпадает: True
|
||
|
||
## Сверка: объект без метаданных
|
||
$ sh scripts/reconcile-demo.sh
|
||
## Отказ между S3 и БД: объект есть, строки нет
|
||
Name : orphan-1793887242
|
||
|
||
## Свежий объект, grace 3600 с, --apply: не удалён
|
||
{"mode":"apply","grace_seconds":3600,"scanned":12,"fresh_skipped":12,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":294}
|
||
объект на месте
|
||
|
||
## Dry-run, grace 1 с: найден, не удалён
|
||
{"mode":"dry-run","grace_seconds":1,"scanned":12,"fresh_skipped":0,"referenced":11,"orphans":1,"deleted":0,"failed":0,"orphan_keys":["attachments/orphan-1793887242"],"duration_ms":299}
|
||
объект на месте
|
||
|
||
## --apply, grace 1 с: удалён только он
|
||
{"mode":"apply","grace_seconds":1,"scanned":12,"fresh_skipped":0,"referenced":11,"orphans":1,"deleted":1,"failed":0,"orphan_keys":["attachments/orphan-1793887242"],"duration_ms":305}
|
||
объект удалён
|
||
|
||
## Повторный запуск: удалять нечего
|
||
{"mode":"apply","grace_seconds":1,"scanned":11,"fresh_skipped":0,"referenced":11,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":292}
|
||
|
||
## Журнал постоянного сервиса reconciler
|
||
{"mode":"apply","grace_seconds":3600,"scanned":0,"fresh_skipped":0,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":219}
|