fix(agent99): move dispatch reconciler to signal worker
This commit is contained in:
@@ -622,6 +622,7 @@ async def _main() -> None:
|
||||
ansible_candidate_backfill_task: asyncio.Task[Any] | None = None
|
||||
backup_restore_legacy_backfill_task: asyncio.Task[Any] | None = None
|
||||
security_maintenance_tasks: list[asyncio.Task[Any]] = []
|
||||
agent99_controlled_dispatch_reconciler_task: asyncio.Task[Any] | None = None
|
||||
if settings.ENABLE_AWOOOP_ANSIBLE_CANDIDATE_BACKFILL_WORKER:
|
||||
from src.jobs.awooop_ansible_candidate_backfill_job import (
|
||||
run_awooop_ansible_candidate_backfill_loop,
|
||||
@@ -686,6 +687,41 @@ async def _main() -> None:
|
||||
task_names=[task.get_name() for task in security_maintenance_tasks],
|
||||
task_count=len(security_maintenance_tasks),
|
||||
)
|
||||
|
||||
# 2026-07-14 Codex v1.4: Agent99 reconciliation has one runtime owner.
|
||||
# The API reserves its single DB connection for requests, so durable
|
||||
# dispatch completion belongs to this standalone worker after the CD-owned
|
||||
# schema migration / optional local bootstrap block above has completed.
|
||||
if (
|
||||
settings.AGENT99_SRE_ALERT_RELAY_URL.strip()
|
||||
and settings.AGENT99_SRE_ALERT_RELAY_TOKEN.strip()
|
||||
):
|
||||
from src.jobs.agent99_controlled_dispatch_reconciler_job import (
|
||||
run_agent99_controlled_dispatch_reconciler_loop,
|
||||
)
|
||||
|
||||
agent99_controlled_dispatch_reconciler_task = asyncio.create_task(
|
||||
run_agent99_controlled_dispatch_reconciler_loop(),
|
||||
name="run_agent99_controlled_dispatch_reconciler_loop",
|
||||
)
|
||||
logger.info(
|
||||
"signal_worker_agent99_controlled_dispatch_reconciler_started",
|
||||
owner="signal_worker",
|
||||
interval_seconds=15,
|
||||
authenticated_relay_configured=True,
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
"signal_worker_agent99_controlled_dispatch_reconciler_skipped_fail_closed",
|
||||
owner="signal_worker",
|
||||
reason="authenticated_relay_not_configured",
|
||||
relay_url_configured=bool(
|
||||
settings.AGENT99_SRE_ALERT_RELAY_URL.strip()
|
||||
),
|
||||
relay_token_configured=bool(
|
||||
settings.AGENT99_SRE_ALERT_RELAY_TOKEN.strip()
|
||||
),
|
||||
)
|
||||
# Setup graceful shutdown
|
||||
shutdown_event = asyncio.Event()
|
||||
|
||||
@@ -727,6 +763,12 @@ async def _main() -> None:
|
||||
task.cancel()
|
||||
if security_maintenance_tasks:
|
||||
await asyncio.gather(*security_maintenance_tasks, return_exceptions=True)
|
||||
if agent99_controlled_dispatch_reconciler_task is not None:
|
||||
agent99_controlled_dispatch_reconciler_task.cancel()
|
||||
try:
|
||||
await agent99_controlled_dispatch_reconciler_task
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
await worker.stop()
|
||||
await close_worker_redis_pool() # 關閉 Worker 專屬連線
|
||||
await close_redis_pool()
|
||||
|
||||
Reference in New Issue
Block a user