-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-130591 / 24.10-RC.1 /
Other TrueNAS controller is inaccessible
…
…proactive support alert (by themylogin) (#14375) * `Other TrueNAS controller is inaccessible` proactive support alert (cherry picked from commit e796aed) * Proactive support: also notify gone alerts when requested (cherry picked from commit f188d7a) * Add incident ID (cherry picked from commit 62b36c1) * Fix (cherry picked from commit 4cb1e74) --------- Co-authored-by: themylogin <[email protected]>
- Loading branch information
1 parent
5f3d286
commit 09e3883
Showing
3 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/middlewared/middlewared/alert/source/failover_remote_inaccessible.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (c) - iXsystems Inc. | ||
# | ||
# Licensed under the terms of the TrueNAS Enterprise License Agreement | ||
# See the file LICENSE.IX for complete terms and conditions | ||
|
||
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. Incident ID: %s.' | ||
products = ('SCALE_ENTERPRISE',) | ||
proactive_support = True | ||
proactive_support_notify_gone = True | ||
|
||
|
||
class FailoverRemoteSystemInaccessibleAlertSource(AlertSource): | ||
products = ('SCALE_ENTERPRISE',) | ||
failover_related = True | ||
run_on_backup_node = False | ||
|
||
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: | ||
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 [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters