fix(api): bound ansible backfill query cost
This commit is contained in:
@@ -705,12 +705,12 @@ class Settings(BaseSettings):
|
||||
),
|
||||
)
|
||||
AWOOOP_ANSIBLE_CANDIDATE_BACKFILL_INTERVAL_SECONDS: int = Field(
|
||||
default=300,
|
||||
default=600,
|
||||
ge=60,
|
||||
description="Polling interval for the Ansible candidate backfill worker.",
|
||||
)
|
||||
AWOOOP_ANSIBLE_CANDIDATE_BACKFILL_BATCH_LIMIT: int = Field(
|
||||
default=5,
|
||||
default=2,
|
||||
ge=1,
|
||||
le=25,
|
||||
description="Maximum backfilled incidents queued per worker tick.",
|
||||
|
||||
@@ -43,6 +43,7 @@ async def _fetch_missing_candidate_incidents(
|
||||
scan_limit: int,
|
||||
) -> list[dict[str, Any]]:
|
||||
async with get_db_context(project_id) as db:
|
||||
await db.execute(text("SET LOCAL statement_timeout = '5000ms'"))
|
||||
result = await db.execute(
|
||||
text("""
|
||||
SELECT
|
||||
@@ -69,6 +70,7 @@ async def _fetch_missing_candidate_incidents(
|
||||
SELECT 1
|
||||
FROM automation_operation_log existing
|
||||
WHERE existing.operation_type = 'ansible_candidate_matched'
|
||||
AND existing.created_at >= NOW() - (:window_hours * INTERVAL '1 hour')
|
||||
AND existing.input ->> 'executor' = 'ansible'
|
||||
AND coalesce(existing.incident_id::text, existing.input ->> 'incident_id') = incidents.incident_id::text
|
||||
)
|
||||
|
||||
@@ -648,6 +648,7 @@ async def backfill_missing_auto_repair_execution_receipts_once(
|
||||
stats = {"scanned": 0, "written": 0, "skipped": 0, "error": None}
|
||||
try:
|
||||
async with get_db_context(project_id) as db:
|
||||
await db.execute(text("SET LOCAL statement_timeout = '5000ms'"))
|
||||
result = await db.execute(
|
||||
text("""
|
||||
SELECT
|
||||
@@ -667,7 +668,9 @@ async def backfill_missing_auto_repair_execution_receipts_once(
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM auto_repair_executions existing
|
||||
WHERE existing.executed_steps::text LIKE '%' || apply.op_id::text || '%'
|
||||
WHERE existing.created_at >= NOW() - (:window_hours * INTERVAL '1 hour')
|
||||
AND existing.triggered_by = 'ansible_controlled_apply'
|
||||
AND existing.executed_steps::text LIKE '%' || apply.op_id::text || '%'
|
||||
)
|
||||
ORDER BY apply.created_at DESC
|
||||
LIMIT :limit
|
||||
|
||||
@@ -140,9 +140,9 @@ spec:
|
||||
- name: ENABLE_AWOOOP_ANSIBLE_CANDIDATE_BACKFILL_WORKER
|
||||
value: "true"
|
||||
- name: AWOOOP_ANSIBLE_CANDIDATE_BACKFILL_INTERVAL_SECONDS
|
||||
value: "300"
|
||||
value: "600"
|
||||
- name: AWOOOP_ANSIBLE_CANDIDATE_BACKFILL_BATCH_LIMIT
|
||||
value: "5"
|
||||
value: "2"
|
||||
- name: AWOOOP_ANSIBLE_CANDIDATE_BACKFILL_WINDOW_HOURS
|
||||
value: "24"
|
||||
- name: AWOOOP_ANSIBLE_CANDIDATE_BACKFILL_STARTUP_SLEEP_SECONDS
|
||||
|
||||
Reference in New Issue
Block a user