Remove task import from jail_config_service and mark TASK-03 done

This commit is contained in:
2026-04-14 14:38:43 +02:00
parent 2a7766d206
commit 41f8c1f6cb
3 changed files with 13 additions and 4 deletions

View File

@@ -87,7 +87,9 @@ Blocking I/O on the event loop is forbidden by the architecture's "Async Everyth
---
### TASK-03 — Remove inverted dependency: service importing a task 🟠
### TASK-03 — Remove inverted dependency: service importing a task
**Status:** Completed ✅
**Where:**
`backend/app/services/jail_config_service.py` — line 37:

View File

@@ -174,3 +174,5 @@ async def probe(socket_path: str, timeout: float = _SOCKET_TIMEOUT) -> ServerSta
except ValueError as exc:
log.error("fail2ban_probe_parse_error", error=str(exc))
return ServerStatus(online=False)

View File

@@ -34,7 +34,7 @@ from app.models.config import (
JailValidationResult,
RollbackResponse,
)
from app.tasks.health_check import run_probe
from app.services import health_service
from app.utils.async_utils import run_blocking
from app.utils.fail2ban_client import Fail2BanClient
from app.utils.runtime_state import (
@@ -61,6 +61,11 @@ _META_SECTIONS: frozenset[str] = frozenset({"INCLUDES", "DEFAULT"})
# Seconds to wait between fail2ban liveness probes after a reload.
_POST_RELOAD_PROBE_INTERVAL: float = 2.0
async def run_probe(socket_path: str) -> "ServerStatus":
"""Run a health probe against the fail2ban socket."""
return await health_service.probe(socket_path)
# Maximum number of post-reload probe attempts (initial attempt + retries).
_POST_RELOAD_MAX_ATTEMPTS: int = 4
@@ -292,7 +297,7 @@ async def activate_jail(
activated_at=activation_time,
)
await run_probe(app)
await run_probe(socket_path)
return result
@@ -568,7 +573,7 @@ async def deactivate_jail(
the current daemon state.
"""
result = await _deactivate_jail(config_dir, socket_path, name)
await run_probe(app)
await run_probe(socket_path)
return result