Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Respect deployment telemetry lock in notification CI journey

pulse-triage[bot]89a3381ffc5a
diff --git a/scripts/check_notification_runtime.py b/scripts/check_notification_runtime.py
index 4c7fe197f3..3efe994f71 100644
--- a/scripts/check_notification_runtime.py
+++ b/scripts/check_notification_runtime.py
@@ -225,10 +225,21 @@ class Journey:
{'name': 'unlisted-loopback', 'url': f'http://127.0.0.2:{self.sink.port}/blocked',
'enabled': True, 'method': 'POST', 'service': 'generic'}, expected=400)
+ def save_system_policy(self):
+ # This process's deployment owns telemetry=false. Do not weaken that
+ # lock or include its field in an otherwise unrelated settings patch.
+ self.request('/api/system/settings/update', {'telemetryEnabled': False}, expected=409)
+ self.phase('deployment-telemetry-lock-preserved')
+ self.request('/api/system/settings/update', {'publicURL': PUBLIC_URL,
+ 'webhookAllowedPrivateCIDRs': '127.0.0.1/32'})
+
def assert_settings(self):
settings = self.request('/api/system/settings')
require(settings.get('publicURL') == PUBLIC_URL and
settings.get('webhookAllowedPrivateCIDRs') == '127.0.0.1/32', 'saved system policy changed')
+ require(settings.get('telemetryEnabled') is False and
+ settings.get('envOverrides', {}).get('PULSE_TELEMETRY') is True,
+ 'deployment telemetry restriction changed')
cfg = self.request('/api/alerts/config')
require(cfg.get('enabled') and cfg.get('activationState') == 'active' and
cfg.get('agentDefaults', {}).get('cpu', {}).get('trigger') == 80,
@@ -277,8 +288,7 @@ class Journey:
require(any(c.name == 'pulse_csrf' for c in self.cookies), 'login missing CSRF cookie')
require(self.request('/api/resources?limit=500').get('data') == [], 'initial live estate not empty')
self.phase('authenticated-empty-live-startup')
- self.request('/api/system/settings/update', {'publicURL': PUBLIC_URL,
- 'webhookAllowedPrivateCIDRs': '127.0.0.1/32', 'telemetryEnabled': False})
+ self.save_system_policy()
self.denied_destination()
self.request('/api/notifications/webhooks', {'name': 'owned-first-alert',
'url': f'http://127.0.0.1:{self.sink.port}/owned-alert', 'enabled': True,
diff --git a/scripts/tests/test_notification_runtime.py b/scripts/tests/test_notification_runtime.py
index 7d9ad138d4..3eb2f7ac1e 100644
--- a/scripts/tests/test_notification_runtime.py
+++ b/scripts/tests/test_notification_runtime.py
@@ -103,6 +103,37 @@ class NotificationRuntimeControls(unittest.TestCase):
journey.request('/api/resources')
journey.client.open.assert_called_once()
+ def test_settings_patch_preserves_and_tests_deployment_telemetry_lock(self):
+ journey = self.journey()
+ journey.request = mock.Mock()
+ with contextlib.redirect_stdout(io.StringIO()):
+ journey.save_system_policy()
+ self.assertEqual(journey.request.call_args_list, [
+ mock.call('/api/system/settings/update', {'telemetryEnabled': False}, expected=409),
+ mock.call('/api/system/settings/update', {'publicURL': RUNTIME.PUBLIC_URL,
+ 'webhookAllowedPrivateCIDRs': '127.0.0.1/32'})])
+ self.assertEqual(journey.phases, ['deployment-telemetry-lock-preserved'])
+ handler = (ROOT / 'internal/api/system_settings.go').read_text()
+ self.assertIn('rawRequest["telemetryEnabled"]; ok && h.config.EnvOverrides["PULSE_TELEMETRY"]', handler)
+
+ def test_policy_readback_requires_disabled_locked_telemetry(self):
+ system = {'publicURL': RUNTIME.PUBLIC_URL, 'webhookAllowedPrivateCIDRs': '127.0.0.1/32',
+ 'telemetryEnabled': False, 'envOverrides': {'PULSE_TELEMETRY': True}}
+ alerts = {'enabled': True, 'activationState': 'active',
+ 'agentDefaults': {'cpu': {'trigger': 80}}}
+ for telemetry, lock, allowed in [(False, True, True), (True, True, False),
+ (None, True, False), (False, False, False)]:
+ with self.subTest(telemetry=telemetry, lock=lock):
+ journey = self.journey()
+ settings = copy.deepcopy(system)
+ settings['telemetryEnabled'], settings['envOverrides']['PULSE_TELEMETRY'] = telemetry, lock
+ journey.request = mock.Mock(side_effect=[settings, alerts])
+ if allowed:
+ journey.assert_settings()
+ else:
+ with self.assertRaisesRegex(RUNTIME.Failure, 'telemetry restriction'):
+ journey.assert_settings()
+
def test_only_clean_matching_checkout_and_binary_admitted(self):
valid = '\tbuild\tvcs=git\n\tbuild\tvcs.revision=' + SHA + '\n\tbuild\tvcs.modified=false\n'
cases = [(SHA, 0, valid, True),