fix(iwooos): retry expired Wazuh posture claim
All checks were successful
CD Pipeline / select-latest-carrier (push) Successful in 57s
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m38s
CD Pipeline / revalidate-deploy-carrier (push) Successful in 36s
CD Pipeline / build-and-deploy (push) Successful in 14m55s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 0s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 30s
CD Pipeline / revalidate-post-deploy-carrier (push) Successful in 38s
CD Pipeline / post-deploy-checks (push) Successful in 2m11s

This commit is contained in:
Your Name
2026-07-22 18:02:45 +08:00
parent fe56928b89
commit ac1a30109b
2 changed files with 125 additions and 0 deletions

View File

@@ -70,6 +70,7 @@ _WAZUH_INCOMPLETE_RUNTIME_RETRY_REASONS = frozenset(
"controlled_apply_failed",
"post_apply_learning_incomplete",
"recipient_visible_transition_missing",
"scheduled_candidate_recurrence_expired_before_claim",
}
)
_WAZUH_INGRESS_CATALOG_ID = "ansible:wazuh-alertmanager-integration"
@@ -1219,6 +1220,8 @@ async def enqueue_iwooos_wazuh_manager_posture_candidate_once(
telegram.send_status AS latest_telegram_send_status,
telegram.provider_message_id
AS latest_telegram_provider_message_id,
execution_skip.input ->> 'not_used_reason'
AS latest_execution_skip_reason,
EXISTS (
SELECT 1
FROM incident_evidence evidence
@@ -1290,6 +1293,14 @@ async def enqueue_iwooos_wazuh_manager_posture_candidate_once(
ORDER BY packet.created_at DESC
LIMIT 1
) capability_packet ON TRUE
LEFT JOIN LATERAL (
SELECT skipped.input
FROM automation_operation_log skipped
WHERE skipped.parent_op_id = candidate.op_id
AND skipped.operation_type = 'ansible_execution_skipped'
ORDER BY skipped.created_at DESC, skipped.op_id DESC
LIMIT 1
) execution_skip ON TRUE
LEFT JOIN LATERAL (
SELECT outbound.send_status,
outbound.provider_message_id
@@ -1681,6 +1692,10 @@ async def enqueue_iwooos_wazuh_manager_posture_candidate_once(
retry_attempt_ref = f"{deploy_ref}-learning"
elif retry_reason == "recipient_visible_transition_missing":
retry_attempt_ref = f"{deploy_ref}-receipt"
elif retry_reason == (
"scheduled_candidate_recurrence_expired_before_claim"
):
retry_attempt_ref = f"{deploy_ref}-recurrence"
elif latest_check_status == "success":
retry_attempt_ref = f"{deploy_ref}-context"
retry_reason = "predecision_context"
@@ -2001,6 +2016,11 @@ def _wazuh_posture_retry_reason(
check_status = str(existing_row.get("latest_check_status") or "")
apply_status = str(existing_row.get("latest_apply_status") or "")
learning_status = str(existing_row.get("latest_learning_status") or "")
execution_skip_reason = str(
existing_row.get("latest_execution_skip_reason") or ""
)
if execution_skip_reason == "scheduled_candidate_identity_chain_not_verified":
return "scheduled_candidate_recurrence_expired_before_claim"
if check_status == "failed":
return "check_mode_failed"
if apply_status == "failed":