Fix geo_re_resolve async mocks and mark tasks complete

This commit is contained in:
2026-03-17 18:54:25 +01:00
parent 25d43ffb96
commit 6515164d53
12 changed files with 208 additions and 136 deletions

View File

@@ -18,7 +18,7 @@ within 60 seconds of that activation, a
from __future__ import annotations
import datetime
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, TypedDict
import structlog
@@ -31,6 +31,14 @@ if TYPE_CHECKING: # pragma: no cover
log: structlog.stdlib.BoundLogger = structlog.get_logger()
class ActivationRecord(TypedDict):
"""Stored timestamp data for a jail activation event."""
jail_name: str
at: datetime.datetime
#: How often the probe fires (seconds).
HEALTH_CHECK_INTERVAL: int = 30
@@ -39,7 +47,7 @@ HEALTH_CHECK_INTERVAL: int = 30
_ACTIVATION_CRASH_WINDOW: int = 60
async def _run_probe(app: Any) -> None:
async def _run_probe(app: "FastAPI") -> None:
"""Probe fail2ban and cache the result on *app.state*.
Detects online/offline state transitions. When fail2ban goes offline
@@ -86,7 +94,7 @@ async def _run_probe(app: Any) -> None:
elif not status.online and prev_status.online:
log.warning("fail2ban_went_offline")
# Check whether this crash happened shortly after a jail activation.
last_activation: dict[str, Any] | None = getattr(
last_activation: ActivationRecord | None = getattr(
app.state, "last_activation", None
)
if last_activation is not None: