This commit is contained in:
@@ -232,6 +232,11 @@ class AutoHealService:
|
||||
record_autoheal_action(action="NO_PLAYBOOK", error_type=error_type, success=False)
|
||||
return AutoHealResult(success=False, action=None, message=msg)
|
||||
|
||||
playbook_id = int(playbook.get("id") or 0)
|
||||
if playbook_id > 0:
|
||||
context["matched_playbook_id"] = playbook_id
|
||||
context["playbook_id"] = playbook_id
|
||||
|
||||
if playbook["action_type"] not in _ALLOWED_ACTION_TYPES:
|
||||
msg = f"action_type '{playbook['action_type']}' is not allowed"
|
||||
self._log.warning("[AutoHeal] %s", msg)
|
||||
@@ -317,6 +322,7 @@ class AutoHealService:
|
||||
error_type=error_type,
|
||||
error_message=str(context.get("exception") or context.get("error_message") or error_type)[:2000],
|
||||
traceback_str=str(context.get("traceback_str") or "")[:8000] or None,
|
||||
error_traceback=str(context.get("traceback_str") or "")[:8000] or None,
|
||||
severity=str(context.get("severity") or "medium"),
|
||||
status="healing",
|
||||
retry_count=0,
|
||||
@@ -569,15 +575,28 @@ class AutoHealService:
|
||||
session = None
|
||||
try:
|
||||
session = get_session()
|
||||
status = "closed" if result.success else "escalated"
|
||||
playbook_id = int(
|
||||
context.get("matched_playbook_id")
|
||||
or context.get("playbook_id")
|
||||
or 0
|
||||
) or None
|
||||
session.execute(
|
||||
text("""
|
||||
UPDATE incidents
|
||||
SET status = :status,
|
||||
matched_playbook_id = COALESCE(:playbook_id, matched_playbook_id),
|
||||
playbook_id = COALESCE(:playbook_id, playbook_id),
|
||||
resolved_at = CASE
|
||||
WHEN :status = 'closed' THEN COALESCE(resolved_at, NOW())
|
||||
ELSE resolved_at
|
||||
END,
|
||||
updated_at = NOW()
|
||||
WHERE id = :incident_id
|
||||
"""),
|
||||
{
|
||||
"status": "closed" if result.success else "escalated",
|
||||
"status": status,
|
||||
"playbook_id": playbook_id,
|
||||
"incident_id": int(incident_id),
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user