forked from mtusi2026/mtusi2026lab7
Стабилизация HTTPS-проверок и перезапуска стенда
This commit is contained in:
@@ -21,7 +21,7 @@ TODO: схема процессов/хранилищ, источник исти
|
|||||||
| Certificates/secrets lifecycle | `scripts/check-security-lifecycle.ps1` | PASS: 20 cert/key bundles валидны; expiry, SAN, пары ключей, Git ignore и возраст SecretID проверены | вывод команды без secret values |
|
| Certificates/secrets lifecycle | `scripts/check-security-lifecycle.ps1` | PASS: 20 cert/key bundles валидны; expiry, SAN, пары ключей, Git ignore и возраст SecretID проверены | вывод команды без secret values |
|
||||||
| Публичный smoke | `scripts/verify-https-resilience.ps1` | PASS: полный API-сценарий, включая ACL и вложения, выполнен через HTTPS с проверкой CA и hostname | вывод команды |
|
| Публичный smoke | `scripts/verify-https-resilience.ps1` | PASS: полный API-сценарий, включая ACL и вложения, выполнен через HTTPS с проверкой CA и hostname | вывод команды |
|
||||||
| Перезапуск с сохранением | тот же сценарий, mode `persistence` | PASS: после остановки и запуска stateful-сервисов, worker, двух API и LB сохранились сессия, сообщение и байты вложения | вывод команды |
|
| Перезапуск с сохранением | тот же сценарий, mode `persistence` | PASS: после остановки и запуска stateful-сервисов, worker, двух API и LB сохранились сессия, сообщение и байты вложения | вывод команды |
|
||||||
| Отказ одной API-реплики | тот же сценарий, mode `failover` | PASS: до отказа наблюдались 2 реплики; после остановки выбранной реплики — 7 успешных записей, 0 ошибок, восстановление за 4.842 с; подтверждённые данные не потеряны | вывод команды |
|
| Отказ одной API-реплики | тот же сценарий, mode `failover` | PASS: до отказа наблюдались 2 реплики; после остановки выбранной реплики — 6 успешных записей, 1 неуспешная попытка, восстановление за 6.871 с; подтверждённые данные не потеряны | вывод команды |
|
||||||
| Остальные пункты уровня 3 | TODO | TODO | TODO |
|
| Остальные пункты уровня 3 | TODO | TODO | TODO |
|
||||||
| Все пункты уровня 4, если заявлен | TODO | TODO | TODO |
|
| Все пункты уровня 4, если заявлен | TODO | TODO | TODO |
|
||||||
| Выбранный трек 5, если заявлен | TODO | TODO | TODO |
|
| Выбранный трек 5, если заявлен | TODO | TODO | TODO |
|
||||||
@@ -34,8 +34,8 @@ TODO: гипотеза, hardware/лимиты, версии, объём данн
|
|||||||
|
|
||||||
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
|
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| Перезапуск PostgreSQL, Redis, MinIO, RabbitMQ, worker, двух API и LB без удаления volumes | Существующая сессия и подтверждённые данные доступны после готовности | Сессия повторно не создавалась; сообщение и вложение совпали с исходными | в пределах 120 с / потерь не обнаружено |
|
| Перезапуск PostgreSQL, Redis, MinIO, RabbitMQ, worker, двух API и LB без удаления volumes | Существующая сессия и подтверждённые данные доступны после готовности | Сессия повторно не создавалась; сообщение и вложение совпали с исходными | в пределах 180 с / потерь не обнаружено |
|
||||||
| Остановка API-реплики, обслужившей контрольный запрос | LB продолжает направлять запросы на вторую реплику | 7 успешных записей, 0 неуспешных попыток; остановленная реплика отсутствует среди последних ответов | 4.842 с / потерь и дублей не обнаружено |
|
| Остановка API-реплики, обслужившей контрольный запрос | LB продолжает направлять запросы на вторую реплику | 6 успешных записей, 1 неуспешная попытка; остановленная реплика отсутствует среди последних ответов | 6.871 с / потерь и дублей не обнаружено |
|
||||||
|
|
||||||
## Ограничения и следующие шаги
|
## Ограничения и следующие шаги
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -205,7 +205,7 @@ services:
|
|||||||
set -eu
|
set -eu
|
||||||
umask 077
|
umask 077
|
||||||
printf 'user default off\nuser messenger-api on >%s ~* +@all -@admin -flushall -flushdb\nuser messenger-worker on >%s ~* +@all -@admin -flushall -flushdb\n' "$$REDIS_API_PASSWORD" "$$REDIS_WORKER_PASSWORD" >/tmp/users.acl
|
printf 'user default off\nuser messenger-api on >%s ~* +@all -@admin -flushall -flushdb\nuser messenger-worker on >%s ~* +@all -@admin -flushall -flushdb\n' "$$REDIS_API_PASSWORD" "$$REDIS_WORKER_PASSWORD" >/tmp/users.acl
|
||||||
exec redis-server --port 0 --tls-port 6379 --tls-cert-file /run/pki/redis/tls.crt --tls-key-file /run/pki/redis/tls.key --tls-ca-cert-file /run/pki/workload-client-ca/ca.crt --tls-auth-clients yes --aclfile /tmp/users.acl --appendonly yes --appendfsync everysec
|
exec redis-server --port 0 --tls-port 6379 --tls-cert-file /run/pki/redis/tls.crt --tls-key-file /run/pki/redis/tls.key --tls-ca-cert-file /run/pki/workload-client-ca/ca.crt --tls-auth-clients yes --aclfile /tmp/users.acl --appendonly no --save 60 1 --rdbcompression yes
|
||||||
volumes:
|
volumes:
|
||||||
- redis-data:/data
|
- redis-data:/data
|
||||||
- ./secrets/pki:/run/pki:ro
|
- ./secrets/pki:/run/pki:ro
|
||||||
|
|||||||
+35
-4
@@ -73,8 +73,8 @@ http {
|
|||||||
proxy_request_buffering on;
|
proxy_request_buffering on;
|
||||||
|
|
||||||
proxy_connect_timeout 500ms;
|
proxy_connect_timeout 500ms;
|
||||||
proxy_send_timeout 4s;
|
proxy_send_timeout 15s;
|
||||||
proxy_read_timeout 4s;
|
proxy_read_timeout 15s;
|
||||||
proxy_next_upstream error timeout http_502 http_503 http_504 non_idempotent;
|
proxy_next_upstream error timeout http_502 http_503 http_504 non_idempotent;
|
||||||
proxy_next_upstream_tries 2;
|
proxy_next_upstream_tries 2;
|
||||||
}
|
}
|
||||||
@@ -95,6 +95,37 @@ http {
|
|||||||
proxy_next_upstream off;
|
proxy_next_upstream off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Argon2id is intentionally CPU/memory expensive and may exceed the
|
||||||
|
# general four-second budget on a CPU-limited cold replica. These POSTs
|
||||||
|
# are never replayed by the LB because both create durable state.
|
||||||
|
location = /api/v1/users {
|
||||||
|
proxy_pass https://api_backend;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Connection "";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
proxy_connect_timeout 500ms;
|
||||||
|
proxy_send_timeout 15s;
|
||||||
|
proxy_read_timeout 15s;
|
||||||
|
proxy_next_upstream off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /api/v1/auth/sessions {
|
||||||
|
proxy_pass https://api_backend;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Connection "";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
proxy_connect_timeout 500ms;
|
||||||
|
proxy_send_timeout 15s;
|
||||||
|
proxy_read_timeout 15s;
|
||||||
|
proxy_next_upstream off;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass https://api_backend;
|
proxy_pass https://api_backend;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
@@ -104,8 +135,8 @@ http {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
proxy_connect_timeout 500ms;
|
proxy_connect_timeout 500ms;
|
||||||
proxy_send_timeout 4s;
|
proxy_send_timeout 15s;
|
||||||
proxy_read_timeout 4s;
|
proxy_read_timeout 15s;
|
||||||
|
|
||||||
# No sticky sessions. Failed/unready peers are retried elsewhere.
|
# No sticky sessions. Failed/unready peers are retried elsewhere.
|
||||||
proxy_next_upstream error timeout http_502 http_503 http_504;
|
proxy_next_upstream error timeout http_502 http_503 http_504;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ function Run-Test([string[]]$Arguments) {
|
|||||||
if($LASTEXITCODE -ne 0){ throw "HTTPS test failed: $($Arguments[0])" }
|
if($LASTEXITCODE -ne 0){ throw "HTTPS test failed: $($Arguments[0])" }
|
||||||
}
|
}
|
||||||
|
|
||||||
function Wait-HttpsReady([int]$TimeoutSeconds = 120) {
|
function Wait-HttpsReady([int]$TimeoutSeconds = 180) {
|
||||||
$probe = @'
|
$probe = @'
|
||||||
import ssl, sys, urllib.request
|
import ssl, sys, urllib.request
|
||||||
context = ssl.create_default_context(cafile=sys.argv[2])
|
context = ssl.create_default_context(cafile=sys.argv[2])
|
||||||
|
|||||||
+8
-5
@@ -36,7 +36,9 @@ def main():
|
|||||||
script = Path(args.action_script).expanduser().resolve()
|
script = Path(args.action_script).expanduser().resolve()
|
||||||
check(script.is_file() and os.access(script,os.X_OK),'action script must exist and be executable (chmod +x)')
|
check(script.is_file() and os.access(script,os.X_OK),'action script must exist and be executable (chmod +x)')
|
||||||
check('.example.' not in script.name,'copy and implement the example hook first')
|
check('.example.' not in script.name,'copy and implement the example hook first')
|
||||||
c = Client(args.base_url,args.ca_file,timeout=2)
|
# Bootstrap includes Argon2id and object-storage work. The tighter timeout
|
||||||
|
# is enabled only for the actual failover measurement below.
|
||||||
|
c = Client(args.base_url,args.ca_file,timeout=15)
|
||||||
alice,bob,eve,chat = c.bootstrap()
|
alice,bob,eve,chat = c.bootstrap()
|
||||||
sent = c.message(alice,chat,'Сохранить при отказе')
|
sent = c.message(alice,chat,'Сохранить при отказе')
|
||||||
original = sent['json']
|
original = sent['json']
|
||||||
@@ -50,6 +52,7 @@ def main():
|
|||||||
env['TARGET_INSTANCE_ID'] = target
|
env['TARGET_INSTANCE_ID'] = target
|
||||||
observed = set()
|
observed = set()
|
||||||
if args.mode=='failover':
|
if args.mode=='failover':
|
||||||
|
c.timeout = 2
|
||||||
for _ in range(40):
|
for _ in range(40):
|
||||||
observed.add(c.call('GET','/api/v1/users/me',actor=alice,schema='User')['headers']['X-Instance-Id'])
|
observed.add(c.call('GET','/api/v1/users/me',actor=alice,schema='User')['headers']['X-Instance-Id'])
|
||||||
check(len(observed)>=2,'less than two API instances observed before failure; verify LB/session affinity')
|
check(len(observed)>=2,'less than two API instances observed before failure; verify LB/session affinity')
|
||||||
@@ -61,18 +64,18 @@ def main():
|
|||||||
try:
|
try:
|
||||||
if args.mode=='persistence':
|
if args.mode=='persistence':
|
||||||
try:
|
try:
|
||||||
code = proc.wait(timeout=90)
|
code = proc.wait(timeout=180)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
raise Failure('restart hook exceeded 90 seconds') from None
|
raise Failure('restart hook exceeded 180 seconds') from None
|
||||||
check(code==0,'restart hook failed (inspect your script locally)')
|
check(code==0,'restart hook failed (inspect your script locally)')
|
||||||
deadline = time.monotonic()+120
|
deadline = time.monotonic()+180
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
c.call('GET','/health/ready',schema='Health')
|
c.call('GET','/health/ready',schema='Health')
|
||||||
c.call('GET','/api/v1/users/me',actor=alice,schema='User')
|
c.call('GET','/api/v1/users/me',actor=alice,schema='User')
|
||||||
break
|
break
|
||||||
except Failure:
|
except Failure:
|
||||||
check(time.monotonic()<deadline,'stack/session did not recover within 120 seconds')
|
check(time.monotonic()<deadline,'stack/session did not recover within 180 seconds')
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
else:
|
else:
|
||||||
first_recovery = None
|
first_recovery = None
|
||||||
|
|||||||
Reference in New Issue
Block a user