fix(alerts): краш при restart-политике, гистерезис закрытия, редкие правки
CI / ruff · mypy · pytest (pull_request) Successful in 24m47s
CI / ruff · mypy · pytest (pull_request) Successful in 24m47s
Найдено смоуком на живых контейнерах (examples/, #19): - контейнер с restart: on-failure поднимается за секунду — между раундами его не видно в exited; краш теперь распознаётся и по росту RestartCount (сравнение со снапшотами до текущего раунда), повторы — счётчик - алерт закрывается, только когда условия нет resolve_after (60 с): иначе флапающий сервис получал бы «✅ восстановлено» после каждого раунда - правки сообщений со счётчиком — не чаще раза в минуту на алерт Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,9 +61,16 @@ def test_crash_oom_and_clean_stop() -> None:
|
||||
|
||||
|
||||
def test_restart_loop_counts_within_window() -> None:
|
||||
history = [snap(900, restarts=0), snap(500, restarts=2), snap(60, restarts=4)]
|
||||
history = [snap(900, restarts=0), snap(500, restarts=2), snap(60, restarts=5)]
|
||||
assert kinds(Observation(RUNNING, CALM), history) == {AlertKind.RESTART_LOOP} # 5 - 2 ≥ 3 within 10 min
|
||||
assert kinds(Observation(replace(RUNNING, restart_count=4), CALM), history) == set()
|
||||
assert kinds(Observation(replace(RUNNING, restart_count=4), CALM), history[:2]) == {AlertKind.CRASH} # 2 → 4
|
||||
|
||||
|
||||
def test_crash_seen_through_restart_policy() -> None:
|
||||
"""Restarted between two rounds: the container is running again, but the restart count gave it away."""
|
||||
[crash] = container_conditions(Observation(replace(RUNNING, restart_count=6), CALM), [snap(15)], CFG, NOW)
|
||||
assert crash.kind is AlertKind.CRASH and crash.bump and crash.payload["exit_code"] == "≠ 0"
|
||||
assert kinds(Observation(replace(RUNNING, state="restarting"), None), [snap(15)]) == {AlertKind.CRASH}
|
||||
|
||||
|
||||
def test_unhealthy() -> None:
|
||||
|
||||
Reference in New Issue
Block a user