Исправить замечания ревью: ACL при повторе, повтор POST в nginx, активная проверка готовности

This commit is contained in:
alenchha
2026-10-29 17:30:19 +03:00
parent af5b4ba6a6
commit c001061e18
18 changed files with 388 additions and 179 deletions
+2 -2
View File
@@ -1,11 +1,11 @@
=== Failover run 1 ===
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 121, "failed_attempts": 0, "first_recovery_seconds": 1.463}
{"observed_instances_before": 2, "successful_writes": 130, "failed_attempts": 0, "first_recovery_seconds": 0.333}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
=== Failover run 2 (other replica) ===
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 120, "failed_attempts": 1, "first_recovery_seconds": 1.455}
{"observed_instances_before": 2, "successful_writes": 130, "failed_attempts": 0, "first_recovery_seconds": 0.325}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+39
View File
@@ -0,0 +1,39 @@
### Before fixes (commit fbb8916)
== 1. Idempotent replay after membership removal
PASS: first POST with key -> 201 (got 201)
PASS: history after removal -> 404 (got 404)
FAIL: replay with same key and body after removal -> 404 (got 201)
== 2. Live but not ready api-1 (no route to PostgreSQL)
FAIL: nginx active check marks api-1 down in upstream
PASS: Docker marks api-1 unhealthy
FAIL: 40 GET /users/me with warm session: served by not-ready api-1 = 20
PASS: 40 GET /users/me: 200 responses = 40
PASS: 20 POST messages during outage -> all 201 (got [201])
== 3. LB does not transparently retry non-idempotent POST /chats
PASS: chats in DB (11) == 201 responses (11), POST /chats codes=[201, 201, 201, 201, 201, 201, 201, 201, 201, 201]
FAIL: nginx access log: 12 POST /chats, sent to two upstreams: 3
FAIL: non_idempotent only on messages route: {'/': True}
PASS: api-1 healthy again after PostgreSQL route restored
PASS: api-1 returns to LB rotation
PASS: nginx upstream has no servers marked down
RESULT: FAIL (5)
### After fixes
== 1. Idempotent replay after membership removal
PASS: first POST with key -> 201 (got 201)
PASS: history after removal -> 404 (got 404)
PASS: replay with same key and body after removal -> 404 (got 404)
== 2. Live but not ready api-1 (no route to PostgreSQL)
PASS: nginx active check marks api-1 down in upstream
PASS: Docker marks api-1 unhealthy
PASS: 40 GET /users/me with warm session: served by not-ready api-1 = 0
PASS: 40 GET /users/me: 200 responses = 40
PASS: 20 POST messages during outage -> all 201 (got [201])
== 3. LB does not transparently retry non-idempotent POST /chats
PASS: chats in DB (9) == 201 responses (9), POST /chats codes=[503, 201, 503, 201, 201, 201, 201, 201, 201, 201]
PASS: nginx access log: 12 POST /chats, sent to two upstreams: 0
PASS: non_idempotent only on messages route: {'~ ^/api/v1/chats/[^/]+/messages$': True, '/': False}
PASS: api-1 healthy again after PostgreSQL route restored
PASS: api-1 returns to LB rotation
PASS: nginx upstream has no servers marked down
RESULT: PASS
+5 -5
View File
@@ -4,14 +4,14 @@
"requested_duration_seconds": 60.0,
"elapsed_seconds": 60.012,
"concurrency": 4,
"successful_requests": 53067,
"successful_requests": 54625,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 884.267,
"successful_rps": 910.231,
"successful_latency_ms": {
"p50": 3.936,
"p95": 6.112,
"p99": 18.691
"p50": 3.848,
"p95": 5.7,
"p99": 17.851
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+9 -10
View File
@@ -1,22 +1,21 @@
=== rolling update ===
14:22:50 recreate api-1 (old container df4ba056eb90)
14:22:56 api-1 healthy (new container 53a60bfc9073)
14:23:06 recreate api-2 (old container 6b53175a3693)
14:23:12 api-2 healthy (new container 047f8e956a97)
14:14:27 recreate api-1 (old container 572155b7facd)
14:14:33 api-1 healthy (new container a81474023dca)
14:14:43 recreate api-2 (old container 35c30c16ece5)
14:14:49 api-2 healthy (new container 1ac67f968005)
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 60.0,
"elapsed_seconds": 60.012,
"concurrency": 4,
"successful_requests": 53067,
"successful_requests": 54625,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 884.267,
"successful_rps": 910.231,
"successful_latency_ms": {
"p50": 3.936,
"p95": 6.112,
"p99": 18.691
"p50": 3.848,
"p95": 5.7,
"p99": 17.851
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}