Thor contract, part 1: [gandalf] title tag and a read-only API key for Thor
Lint / JS (eslint) (push) Successful in 14s
Lint / Python (flake8) (push) Successful in 1m47s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m48s
Lint / JS (eslint) (pull_request) Successful in 12s
Lint / Python (flake8) (pull_request) Successful in 1m0s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m21s
Test / Python Tests (pytest) (pull_request) Successful in 1m43s
Test / Python Tests (pytest) (push) Successful in 1m6s
Lint / JS (eslint) (push) Successful in 14s
Lint / Python (flake8) (push) Successful in 1m47s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m48s
Lint / JS (eslint) (pull_request) Successful in 12s
Lint / Python (flake8) (pull_request) Successful in 1m0s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m21s
Test / Python Tests (pytest) (pull_request) Successful in 1m43s
Test / Python Tests (pytest) (push) Successful in 1m6s
Titles move to the shared standard [source][auto][gandalf][network] Summary [scope][production][issue], built in one place (ticket_text.title). Checked by running Tinker's TicketHash.php: every Gandalf title shape hashes the same as before, so open tickets keep matching. Thor can read /api/status, /api/events, /api/attention and /api/suppressions with a machine key (Authorization: Bearer, only its SHA-256 in config, read-only, optional source CIDRs; a wrong key is a 401 and never falls back to identity headers). /api/suppressions ?include_ended=1&hours=N returns every suppression in force in the window with start, planned end, actual end and who ended it: new ended_at/ended_by columns, added automatically. Refs #66 (items 1 and 2) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf5d36ed1e
commit
f924ce42c3
9 files changed
+391
-25
No files matched your search
+11
-13
@@ -1638,7 +1638,7 @@ class NetworkMonitor:
|
||||
grace = reboots.grace_for(host, self.cfg.get('monitor', {}))
|
||||
self._open_ticket(
|
||||
event_id, 'host_metrics_missing', host, instance,
|
||||
title=f'[{host}][auto][production][issue][network][single-node] Planned reboot did not come back',
|
||||
title=ticket_text.title(host, 'Planned reboot did not come back'),
|
||||
heading='Host Reboot Alert',
|
||||
facts=[('Host', host), ('Prometheus instance', instance),
|
||||
('Shutdown requested', f'{_fmt_ts(shutdown["at"])} ({shutdown["kind"]})'),
|
||||
@@ -1695,8 +1695,7 @@ class NetworkMonitor:
|
||||
shared = sorted({u['switch'] for h in hosts for u in self._uplinks_for(h, switches)[0]})
|
||||
self._open_ticket(
|
||||
event_id, 'cluster_network_issue', self.cluster_name, '',
|
||||
title=(f'[{self.cluster_name}][auto][production][issue][network][cluster-wide] '
|
||||
f'Multiple hosts reporting interface failures'),
|
||||
title=ticket_text.title(self.cluster_name, 'Multiple hosts reporting interface failures', 'cluster-wide'),
|
||||
heading='Cluster Network Alert',
|
||||
facts=[('Affected hosts', ', '.join(hosts)),
|
||||
('Switches they connect through', ', '.join(shared)),
|
||||
@@ -1715,7 +1714,7 @@ class NetworkMonitor:
|
||||
) -> None:
|
||||
self._open_ticket(
|
||||
event_id, 'host_metrics_missing', host, instance,
|
||||
title=f'[{host}][auto][production][issue][network][single-node] No metrics from host',
|
||||
title=ticket_text.title(host, 'No metrics from host'),
|
||||
heading='Host Metrics Alert',
|
||||
facts=[('Host', host), ('Prometheus instance', instance), ('Detected', _now_utc()),
|
||||
('Consecutive check failures', str(consec)),
|
||||
@@ -1745,7 +1744,7 @@ class NetworkMonitor:
|
||||
if not sup and consec >= self.fail_thresh and not ticket_id:
|
||||
self._open_ticket(
|
||||
event_id, 'monitor_source_unavailable', 'prometheus', '',
|
||||
title='[prometheus][auto][production][issue][network][cluster-wide] Gandalf has no Prometheus data',
|
||||
title=ticket_text.title('prometheus', 'Gandalf has no Prometheus data', 'cluster-wide'),
|
||||
heading='Monitoring Source Alert',
|
||||
facts=[('Prometheus URL', self.prom.url), ('Detected', _now_utc()),
|
||||
('Consecutive check failures', str(consec))],
|
||||
@@ -1763,7 +1762,7 @@ class NetworkMonitor:
|
||||
) -> None:
|
||||
self._open_ticket(
|
||||
event_id, 'interface_down', host, iface,
|
||||
title=f'[{host}][auto][production][issue][network][single-node] Interface {iface} link-down',
|
||||
title=ticket_text.title(host, f'Interface {iface} link-down'),
|
||||
heading='Network Interface Alert',
|
||||
facts=[('Host', host), ('Interface', f'`{iface}`'), ('Detected', _now_utc()),
|
||||
('Consecutive check failures', str(consec))],
|
||||
@@ -1802,7 +1801,7 @@ class NetworkMonitor:
|
||||
name = device['name']
|
||||
self._open_ticket(
|
||||
event_id, 'unifi_device_offline', name, device.get('type', ''),
|
||||
title=f'[{name}][auto][production][issue][network][single-node] UniFi device offline',
|
||||
title=ticket_text.title(name, 'UniFi device offline'),
|
||||
heading='UniFi Device Alert',
|
||||
facts=[('Device', name), ('Type', device.get('type', 'unknown')), ('Model', device.get('model', '')),
|
||||
('Last known IP', device.get('ip', 'unknown')), ('Detected', _now_utc())],
|
||||
@@ -1851,8 +1850,7 @@ class NetworkMonitor:
|
||||
url = ticket_text.cutsheet_url(self._base_url(), p['cable_id'])
|
||||
self._open_ticket(
|
||||
event_id, 'cable_mismatch', p['switch'], p['key'],
|
||||
title=(f'[{p["switch"]}][auto][production][issue][network][single-node] '
|
||||
f'Cable {p["label"]} does not match the cutsheet'),
|
||||
title=ticket_text.title(p['switch'], f'Cable {p["label"]} does not match the cutsheet'),
|
||||
heading='Cutsheet Mismatch',
|
||||
facts=[('Cable', ticket_text.link(p['label'], url)), ('Switch port', f'{p["switch"]} port {p["port"]}'),
|
||||
('Problem', p['detail']), ('Documented path', p['path']), ('Detected', _now_utc())],
|
||||
@@ -1893,7 +1891,7 @@ class NetworkMonitor:
|
||||
) -> None:
|
||||
self._open_ticket(
|
||||
event_id, 'host_unreachable', name, ip,
|
||||
title=f'[{name}][auto][production][issue][network][single-node] Host unreachable',
|
||||
title=ticket_text.title(name, 'Host unreachable'),
|
||||
heading='Host Reachability Alert',
|
||||
facts=[('Host', name), ('IP', ip), ('Detected', _now_utc()),
|
||||
('Consecutive check failures', str(consec)),
|
||||
@@ -1927,7 +1925,7 @@ class NetworkMonitor:
|
||||
if not sup and consec >= self.modem_fail_thresh and not ticket_id:
|
||||
self._queue_wan_ticket({
|
||||
'event_id': event_id, 'event_type': event_type, 'detail': detail,
|
||||
'title': f'[{name}][auto][production][issue][network][cluster-wide] {heading}',
|
||||
'title': ticket_text.title(name, heading, 'cluster-wide'),
|
||||
'name': heading, 'heading': 'WAN Modem Alert',
|
||||
'facts': [('Modem', f'{name} ({self.modem.base_url})'), ('Detected', _now_utc()),
|
||||
('Consecutive check failures', str(consec))],
|
||||
@@ -2155,7 +2153,7 @@ class NetworkMonitor:
|
||||
if not db.check_suppressed(suppressions, 'host', name) and not ticket_id:
|
||||
self._queue_wan_ticket({
|
||||
'event_id': event_id, 'event_type': event_type, 'detail': '',
|
||||
'title': f'[{name}][auto][production][issue][network][cluster-wide] {heading}',
|
||||
'title': ticket_text.title(name, heading, 'cluster-wide'),
|
||||
'name': heading, 'heading': 'WAN Event',
|
||||
'facts': [('Modem', name), ('Reported', _now_utc())],
|
||||
'summary': description, 'checks': [advice], 'priority': priority, 'recovers': False,
|
||||
@@ -2346,7 +2344,7 @@ class NetworkMonitor:
|
||||
return # try again next cycle
|
||||
state['kuma_error'] = str(e)
|
||||
if state.get('suppression_id'):
|
||||
db.deactivate_suppression(state['suppression_id'])
|
||||
db.deactivate_suppression(state['suppression_id'], ended_by='gandalf')
|
||||
if state.get('smart_power_paused'):
|
||||
self._restore_smart_power(state)
|
||||
state.update(finished_at=now, back=bool(back), rebooted=rebooted,
|
||||
|
||||
Reference in new issue
Block a user