From 62b36c1fcc0cce4a239c47299ec3b82614eea2a2 Mon Sep 17 00:00:00 2001 From: themylogin Date: Wed, 28 Aug 2024 15:00:18 +0200 Subject: [PATCH] Add incident ID --- .../alert/source/failover_remote_inaccessible.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/middlewared/middlewared/alert/source/failover_remote_inaccessible.py b/src/middlewared/middlewared/alert/source/failover_remote_inaccessible.py index 1b2d9f5ba32b7..61c45dbb8a20e 100644 --- a/src/middlewared/middlewared/alert/source/failover_remote_inaccessible.py +++ b/src/middlewared/middlewared/alert/source/failover_remote_inaccessible.py @@ -6,13 +6,14 @@ import time from middlewared.alert.base import AlertClass, AlertCategory, AlertLevel, Alert, AlertSource, UnavailableException +from middlewared.utils.crypto import generate_token class FailoverRemoteSystemInaccessibleAlertClass(AlertClass): category = AlertCategory.HA level = AlertLevel.CRITICAL title = 'Other Controller is Inaccessible' - text = 'Other TrueNAS controller is inaccessible. Contact support.' + text = 'Other TrueNAS controller is inaccessible. Contact support. Incident ID: %s.' products = ('SCALE_ENTERPRISE',) proactive_support = True proactive_support_notify_gone = True @@ -26,15 +27,19 @@ class FailoverRemoteSystemInaccessibleAlertSource(AlertSource): def __init__(self, middleware): super().__init__(middleware) self.last_available = time.monotonic() + self.incident_id = None async def check(self): try: await self.middleware.call('failover.call_remote', 'core.ping', {'timeout': 2}) except Exception: if time.monotonic() - self.last_available > 4 * 3600: - return [Alert(FailoverRemoteSystemInaccessibleAlertClass)] + if self.incident_id is None: + self.incident_id = generate_token(16, url_safe=True) + return [Alert(FailoverRemoteSystemInaccessibleAlertClass, args=[self.incident_id])] else: raise UnavailableException() self.last_available = time.monotonic() + self.incident_id = None return []