Mark host interfaces as unused
Lint / JS (eslint) (push) Successful in 44s
Lint / Python (flake8) (push) Successful in 1m40s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m18s
Lint / JS (eslint) (pull_request) Successful in 10s
Security / Python Security (bandit) (pull_request) Successful in 1m13s
Test / Python Tests (pytest) (pull_request) Successful in 1m11s
Lint / Python (flake8) (pull_request) Successful in 50s
Test / Python Tests (pytest) (push) Successful in 1m1s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Lint / JS (eslint) (push) Successful in 44s
Lint / Python (flake8) (push) Successful in 1m40s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m18s
Lint / JS (eslint) (pull_request) Successful in 10s
Security / Python Security (bandit) (pull_request) Successful in 1m13s
Test / Python Tests (pytest) (pull_request) Successful in 1m11s
Lint / Python (flake8) (pull_request) Successful in 50s
Test / Python Tests (pytest) (push) Successful in 1m1s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Ports that are never meant to be up (compute-storage-01 nic1-3, large1's spare NIC and USB adapter) kept their hosts "degraded" and were the source of tonight's false alerts. An admin can now mark an interface unused from the device page, with an optional reason. Unused interfaces raise no link-down alerts, don't count toward the cluster-wide alert or the host's status, and show greyed as "unused" on the dashboard, device page and rack. Marking one closes any open link-down alert on it without a recovery note. New table unused_interfaces, created with the cutsheet tables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aeb7a89e81
commit
3834546f38
9 files changed
+219
-14
No files matched your search
+20
-3
@@ -1045,6 +1045,16 @@ class NetworkMonitor:
|
||||
def _hostname(self, instance: str) -> str:
|
||||
return self._instance_map.get(instance, instance.split(':')[0])
|
||||
|
||||
def _unused_for(self, host: str) -> dict:
|
||||
return (getattr(self, '_unused', None) or {}).get(host) or {}
|
||||
|
||||
def _load_unused(self) -> None:
|
||||
"""Reload the interfaces marked unused (once a cycle; keeps the last list on error)."""
|
||||
try:
|
||||
self._unused = db.get_unused_interfaces()
|
||||
except Exception as e:
|
||||
logger.error(f'Could not load unused interfaces: {e}')
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Tickets: context, and notes when an alert clears
|
||||
# ------------------------------------------------------------------
|
||||
@@ -1229,7 +1239,10 @@ class NetworkMonitor:
|
||||
new_baseline.setdefault(host, {})
|
||||
host_has_regression = False
|
||||
|
||||
unused = self._unused_for(host)
|
||||
for iface, is_up in ifaces.items():
|
||||
if iface in unused:
|
||||
continue # marked unused: no alerts, and it can't count as a regression
|
||||
prev = baseline.get(host, {}).get(iface) # 'up', 'initial_down', or None
|
||||
|
||||
if is_up:
|
||||
@@ -1799,8 +1812,11 @@ class NetworkMonitor:
|
||||
continue # skip Prometheus instances not in config (e.g. LXC app servers)
|
||||
host = self._hostname(instance)
|
||||
phys = {k: v for k, v in ifaces.items()}
|
||||
up_count = sum(1 for v in phys.values() if v)
|
||||
total = len(phys)
|
||||
# Interfaces marked unused don't count toward the host's status
|
||||
unused = self._unused_for(host)
|
||||
counted = {k: v for k, v in phys.items() if k not in unused}
|
||||
up_count = sum(1 for v in counted.values() if v)
|
||||
total = len(counted)
|
||||
if not prom_ok:
|
||||
status = 'unknown'
|
||||
elif total == 0 or up_count == total:
|
||||
@@ -1812,7 +1828,7 @@ class NetworkMonitor:
|
||||
|
||||
hosts[host] = {
|
||||
'ip': instance.split(':')[0],
|
||||
'interfaces': {k: ('up' if v else 'down') for k, v in phys.items()},
|
||||
'interfaces': {k: ('unused' if k in unused else ('up' if v else 'down')) for k, v in phys.items()},
|
||||
'status': status,
|
||||
'source': 'prometheus',
|
||||
}
|
||||
@@ -1855,6 +1871,7 @@ class NetworkMonitor:
|
||||
while True:
|
||||
try:
|
||||
logger.info('Starting network check cycle')
|
||||
self._load_unused()
|
||||
|
||||
# 1. Fetch interface states once: shared by snapshot and alert processing
|
||||
iface_states = self.prom.get_interface_states()
|
||||
|
||||
Reference in new issue
Block a user