fix(agent): prioritize p0 ansible candidates
This commit is contained in:
@@ -586,6 +586,10 @@ def build_ansible_decision_audit_payload(
|
||||
and str((signal.get("labels") or {}).get("namespace") or "").strip()
|
||||
})
|
||||
proposal_risk_level = str(proposal_data.get("risk_level") or "").strip().lower()
|
||||
execution_priority = proposal_data.get("execution_priority", 100)
|
||||
if not isinstance(execution_priority, int) or isinstance(execution_priority, bool):
|
||||
execution_priority = 100
|
||||
execution_priority = max(0, min(execution_priority, 100))
|
||||
idempotency_key = f"ansible-candidate:{project_id}:{incident_id}"
|
||||
input_payload = {
|
||||
"incident_id": incident_id,
|
||||
@@ -602,6 +606,7 @@ def build_ansible_decision_audit_payload(
|
||||
"executor": "ansible",
|
||||
"execution_backend": "ansible",
|
||||
"single_writer_executor": "awoooi-ansible-executor-broker",
|
||||
"execution_priority": execution_priority,
|
||||
"decision_path": decision_path,
|
||||
"idempotency_key": idempotency_key,
|
||||
"router_source_sha": os.getenv("AWOOOI_BUILD_COMMIT_SHA", "")
|
||||
|
||||
@@ -3185,7 +3185,19 @@ async def claim_pending_check_modes(
|
||||
'ansible_execution_skipped'
|
||||
)
|
||||
)
|
||||
ORDER BY candidate.created_at ASC
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN candidate.input ->> 'work_item_id' LIKE 'P0-%'
|
||||
THEN 0
|
||||
WHEN candidate.input ->> 'execution_priority'
|
||||
~ '^[0-9]{1,3}$'
|
||||
THEN LEAST(
|
||||
(candidate.input ->> 'execution_priority')::int,
|
||||
100
|
||||
)
|
||||
ELSE 100
|
||||
END ASC,
|
||||
candidate.created_at ASC
|
||||
LIMIT :limit
|
||||
FOR UPDATE SKIP LOCKED
|
||||
"""),
|
||||
|
||||
Reference in New Issue
Block a user