forked from mtusi2026/mtusi2026lab4
ЛР 4: вложения в S3 (MinIO), reconciler БД<->S3, отчёт и evidence
Перенесён минимум lab3. Добавлены загрузка/скачивание PNG/JPEG через API с потоковой проверкой целостности, метаданные в PostgreSQL и байты в приватном bucket, отдельный S3-пользователь с ограниченными правами, идемпотентный bootstrap bucket, компенсация и reconciler (трек 2), тесты отказов, эксперименты по памяти и согласованности.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
metadata served by api-1
|
||||
ok uploaded via api-2, downloaded via api-1, identical sha256
|
||||
ok restart of all stateful services keeps metadata and original
|
||||
PASS: attachment failover + persistence
|
||||
@@ -0,0 +1,2 @@
|
||||
ok client abort mid-upload sent; server must stay healthy
|
||||
PASS: attachment negative scenarios
|
||||
@@ -0,0 +1,2 @@
|
||||
{"observed_instances_before": 2, "successful_writes": 131, "failed_attempts": 0, "first_recovery_seconds": 0.447}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,10 @@
|
||||
ok truncated PNG, bad filter byte, broken IDAT, 27-byte JPEG stub -> 415
|
||||
ok same defects in images above the full-decode threshold (6 Mpx) -> 415
|
||||
ok valid 6 Mpx PNG accepted
|
||||
ok valid 36 Mpx PNG (116 KiB on the wire, 108 MiB decoded) accepted in 0.1s
|
||||
ok 36 Mpx PNG with bad filter byte -> 415
|
||||
ok whitespace-only, DEL, C1 and dot filenames -> 400
|
||||
ok attachment order preserved in POST, replay and history; reordered body -> 409
|
||||
ok idempotency: [] == absent, invalid keys -> 400, scoped per user
|
||||
ok 12 MiB body -> JSON 413
|
||||
PASS: input hardening
|
||||
@@ -0,0 +1,5 @@
|
||||
valid 3000x2000 baseline accepted 0.08s ok
|
||||
valid 3000x2000 progressive accepted 0.14s ok
|
||||
27-byte stub rejected 415 0.00s ok
|
||||
scan cut in half, no EOI rejected 415 0.00s ok
|
||||
headers only + EOI rejected 415 0.01s ok
|
||||
@@ -0,0 +1,23 @@
|
||||
payload bytes: 8674403
|
||||
round 1 peak MiB per api: {'mtusi-lab4-api-1-1': 114.5, 'mtusi-lab4-api-2-1': 113.7} statuses=[201]
|
||||
round 2 peak MiB per api: {'mtusi-lab4-api-1-1': 115.1, 'mtusi-lab4-api-2-1': 113.5} statuses=[201]
|
||||
round 3 peak MiB per api: {'mtusi-lab4-api-1-1': 115.2, 'mtusi-lab4-api-2-1': 114.0} statuses=[201]
|
||||
{
|
||||
"payload_mib": 8.27,
|
||||
"concurrency": 10,
|
||||
"rounds": 3,
|
||||
"idle_mib": {
|
||||
"mtusi-lab4-api-1-1": 98.2,
|
||||
"mtusi-lab4-api-2-1": 100.4
|
||||
},
|
||||
"peak_mib": {
|
||||
"mtusi-lab4-api-1-1": 115.2,
|
||||
"mtusi-lab4-api-2-1": 114.0
|
||||
},
|
||||
"container_limit_mib": 256,
|
||||
"statuses": {
|
||||
"201": 30
|
||||
},
|
||||
"upload_seconds_median": 0.76,
|
||||
"upload_seconds_max": 0.95
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
payload bytes: 8674403
|
||||
round 1 peak MiB per api: {'mtusi-lab4-api-1-1': 143.7, 'mtusi-lab4-api-2-1': 142.4} statuses=[201]
|
||||
round 2 peak MiB per api: {'mtusi-lab4-api-1-1': 166.1, 'mtusi-lab4-api-2-1': 153.2} statuses=[201]
|
||||
round 3 peak MiB per api: {'mtusi-lab4-api-1-1': 182.3, 'mtusi-lab4-api-2-1': 154.7} statuses=[201]
|
||||
{
|
||||
"payload_mib": 8.27,
|
||||
"concurrency": 10,
|
||||
"rounds": 3,
|
||||
"idle_mib": {
|
||||
"mtusi-lab4-api-1-1": 88.8,
|
||||
"mtusi-lab4-api-2-1": 88.4
|
||||
},
|
||||
"peak_mib": {
|
||||
"mtusi-lab4-api-1-1": 182.3,
|
||||
"mtusi-lab4-api-2-1": 154.7
|
||||
},
|
||||
"container_limit_mib": 256,
|
||||
"statuses": {
|
||||
"201": 30
|
||||
},
|
||||
"upload_seconds_median": 0.82,
|
||||
"upload_seconds_max": 1.28
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,15 @@
|
||||
== published ports of minio (expect none) ==
|
||||
no port 9000/tcp for container mtusi-lab4-minio-1:
|
||||
no port 9001/tcp for container mtusi-lab4-minio-1:
|
||||
== anonymous requests from inside the network ==
|
||||
GET /messenger-attachments/ -> 403
|
||||
GET /messenger-attachments/attachments/does-not-matter -> 403
|
||||
GET /messenger-attachments?list-type=2 -> 403
|
||||
== bucket policy ==
|
||||
Container mtusi-lab4-minio-init-run-ace02363dd5e Creating
|
||||
Container mtusi-lab4-minio-init-run-ace02363dd5e Created
|
||||
Access permission for `local/messenger-attachments` is `private`
|
||||
PASS: bucket is private
|
||||
Container mtusi-lab4-minio-init-run-bb29f48b3cc4 Created
|
||||
Access permission for `local/messenger-attachments` is `private`
|
||||
PASS: bucket is private
|
||||
@@ -0,0 +1,30 @@
|
||||
baseline (data left by earlier tests): {"deleted_objects": 0, "dry_run": true, "grace_seconds": 900, "marked_failed": 0, "missing_objects": 0, "objects_scanned": 113, "orphan_objects": 0, "protected_fresh_objects": 0, "removed_rows": 0, "rows_scanned": 86, "seconds": 0.17, "stale_uploading": 0}
|
||||
== dry-run, grace=900 ==
|
||||
{"deleted_objects": 0, "dry_run": true, "grace_seconds": 900, "marked_failed": 0, "missing_objects": 2, "objects_scanned": 118, "orphan_objects": 0, "protected_fresh_objects": 2, "removed_rows": 0, "rows_scanned": 89, "seconds": 0.087, "stale_uploading": 1}
|
||||
ok dry-run: 1 new stale row (b), 2 old rows protected by young objects (a, h)
|
||||
ok dry-run: 2 new missing objects (e, g)
|
||||
ok dry-run changes nothing
|
||||
== apply, grace=900 ==
|
||||
{"deleted_objects": 0, "dry_run": false, "grace_seconds": 900, "marked_failed": 2, "missing_objects": 2, "objects_scanned": 118, "orphan_objects": 0, "protected_fresh_objects": 2, "removed_rows": 1, "rows_scanned": 89, "seconds": 0.1, "stale_uploading": 1}
|
||||
ok old row whose object is young is kept (a)
|
||||
ok stale row without object removed
|
||||
ok fresh in-flight upload untouched
|
||||
ok fresh orphan object kept inside grace
|
||||
ok old row with a fresh object is left alone
|
||||
ok recently confirmed row is not marked missing
|
||||
ok missing unused object marked failed
|
||||
ok used attachment with object untouched
|
||||
ok used attachment with lost object kept, marked failed
|
||||
== apply after grace expired (grace=2 after 3s) ==
|
||||
{"deleted_objects": 4, "dry_run": false, "grace_seconds": 2, "marked_failed": 1, "missing_objects": 1, "objects_scanned": 115, "orphan_objects": 1, "protected_fresh_objects": 0, "removed_rows": 3, "rows_scanned": 115, "seconds": 0.126, "stale_uploading": 3}
|
||||
ok orphan object deleted after grace
|
||||
ok expired in-flight row collected after grace
|
||||
ok old row + object collected once the object is older than grace (a, h)
|
||||
ok used attachment still untouched
|
||||
== second apply is idempotent ==
|
||||
{"deleted_objects": 0, "dry_run": false, "grace_seconds": 2, "marked_failed": 0, "missing_objects": 0, "objects_scanned": 114, "orphan_objects": 0, "protected_fresh_objects": 0, "removed_rows": 0, "rows_scanned": 114, "seconds": 0.163, "stale_uploading": 0}
|
||||
ok repeat run changes nothing
|
||||
== cost of a full walk, 1000 ready attachments ==
|
||||
{"deleted_objects": 0, "dry_run": true, "grace_seconds": 900, "marked_failed": 0, "missing_objects": 0, "objects_scanned": 1114, "orphan_objects": 0, "protected_fresh_objects": 0, "removed_rows": 0, "rows_scanned": 1087, "seconds": 1.63, "stale_uploading": 0}
|
||||
ok bulk walk finds nothing wrong
|
||||
RESULT: 18/18 checks passed
|
||||
@@ -0,0 +1,5 @@
|
||||
ok S3 down: upload/download/ready -> 503 JSON, metadata and text messages still served through the LB (no 502)
|
||||
ok recovered 2s after S3 start
|
||||
ok ready is 200 again
|
||||
ok hung S3: upload answered 503 in 7.0s
|
||||
PASS: S3 outage behaviour
|
||||
@@ -0,0 +1 @@
|
||||
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
|
||||
Reference in New Issue
Block a user