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
+28
-1
@@ -37,6 +37,7 @@ def client():
|
||||
db.check_suppressed.return_value = False
|
||||
db.get_device_link.return_value = ''
|
||||
db.cutsheet_racks.return_value = []
|
||||
db.get_unused_interfaces.return_value = {}
|
||||
with patch.object(gandalf, '_cfg', CONFIG):
|
||||
yield gandalf.app.test_client()
|
||||
|
||||
@@ -551,7 +552,7 @@ class TestRackFacesAndSettings:
|
||||
things = data['items'][0]['contents']
|
||||
assert [(c['name'], c['slot'], c['chassis']) for c in things] == [('b-box', 1, 'zimaboard-832'),
|
||||
('large1', 2, '')]
|
||||
assert things[1]['interfaces'] == [{'name': 'eth0', 'up': True}]
|
||||
assert things[1]['interfaces'] == [{'name': 'eth0', 'up': True, 'unused': False}]
|
||||
assert things[0]['device'] == 'b-box' and things[0]['ports'] == {}
|
||||
|
||||
def test_saved_racks_replace_config(self, client):
|
||||
@@ -583,3 +584,29 @@ class TestRackFacesAndSettings:
|
||||
assert client.put('/api/cutsheet/racks/1', json={'name': 'x', 'units': 2}, headers=user).status_code == 403
|
||||
gandalf.db.cutsheet_delete_rack.return_value = False
|
||||
assert client.delete('/api/cutsheet/racks/9', headers=AUTH).status_code == 404
|
||||
|
||||
|
||||
class TestUnusedInterfaces:
|
||||
def _url(self, iface='nic1'):
|
||||
gandalf._cutsheet_schema_ready = True
|
||||
return f'/api/device/compute-storage-01/interfaces/{iface}/unused'
|
||||
|
||||
def test_mark_and_clear(self, client):
|
||||
assert client.put(self._url(), json={'reason': ' never cabled '}, headers=AUTH).status_code == 200
|
||||
gandalf.db.set_unused_interface.assert_called_with('compute-storage-01', 'nic1', 'never cabled', 'jared')
|
||||
gandalf.db.clear_unused_interface.return_value = True
|
||||
resp = client.delete(self._url(), headers=AUTH)
|
||||
assert resp.get_json() == {'success': True, 'changed': True}
|
||||
|
||||
def test_needs_admin_json_and_a_sane_name(self, client):
|
||||
user = dict(AUTH, **{'Remote-Groups': 'staff'})
|
||||
with patch.object(gandalf, '_cfg', dict(CONFIG, auth=dict(CONFIG['auth'], allowed_groups=['admin', 'staff']))):
|
||||
assert client.put(self._url(), json={}, headers=user).status_code == 403
|
||||
assert client.put(self._url(), data='x', headers=AUTH).status_code == 400
|
||||
assert client.put(self._url('bad name!'), json={}, headers=AUTH).status_code in (400, 404)
|
||||
|
||||
def test_device_api_lists_them(self, client):
|
||||
gandalf._cutsheet_schema_ready = True
|
||||
gandalf.db.get_unused_interfaces.return_value = {'large1': {'enp36s0': {'reason': 'spare'}}}
|
||||
data = client.get('/api/device/large1', headers=AUTH).get_json()
|
||||
assert data['unused_interfaces'] == {'enp36s0': {'reason': 'spare'}}
|
||||
@@ -117,6 +117,19 @@ class TestDeadHostDetection:
|
||||
mon._process_interfaces({HOST_A: {'eth0': True}}, [])
|
||||
assert ('cluster_network_issue', 'test-cluster', '') in upserted(db)
|
||||
|
||||
def test_unused_interface_never_alerts(self, mon, db):
|
||||
mon._unused = {'alpha': {'eth1': {'reason': 'spare'}}}
|
||||
db.get_baseline.return_value = {'alpha': {'eth0': 'up', 'eth1': 'up'}, 'beta': {'eth0': 'up'}}
|
||||
mon._process_interfaces({HOST_A: {'eth0': True, 'eth1': False}, HOST_B: {'eth0': True}}, [])
|
||||
assert ('interface_down', 'alpha', 'eth1') not in upserted(db)
|
||||
assert not mon.tickets.create.called
|
||||
|
||||
def test_unused_interface_does_not_degrade_the_host(self, mon):
|
||||
mon._unused = {'alpha': {'eth1': {}}}
|
||||
snap = mon._collect_snapshot({HOST_A: {'eth0': True, 'eth1': False}, HOST_B: {'eth0': True}})
|
||||
assert snap['hosts']['alpha']['status'] == 'up'
|
||||
assert snap['hosts']['alpha']['interfaces'] == {'eth0': 'up', 'eth1': 'unused'}
|
||||
|
||||
def test_dead_host_shows_as_down_on_dashboard(self, mon):
|
||||
snap = mon._collect_snapshot({HOST_A: {'eth0': True}})
|
||||
assert snap['hosts']['alpha']['status'] == 'up'
|
||||
|
||||
Reference in new issue
Block a user