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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Name the failed resource in convergence read errors
pulse-triage[bot]1b8adaa2dcb1
diff --git a/scripts/release_control/reconcile_release_convergence.py b/scripts/release_control/reconcile_release_convergence.pyindex 6f40e4f832..f89641ec2c 100644--- a/scripts/release_control/reconcile_release_convergence.py+++ b/scripts/release_control/reconcile_release_convergence.py@@ -195,6 +195,18 @@ def latest_failed_runs(return sorted(result)+def api_read_subject(endpoint: str) -> str:+ """Name the managed resource, never read filters or arbitrary arguments."""+ resource = endpoint.partition("?")[0]+ if (+ len(resource) <= 256+ and re.fullmatch(r"repos/rcourtman/(?:Pulse|pulse-pro)(?:/[A-Za-z0-9_.-]+)*", resource)+ and ".." not in resource.split("/")+ ):+ return f"GET {resource}"+ return "GitHub API read"++class GitHub:def __init__(self,@@ -216,6 +228,7 @@ class GitHub:output: bool = True,token: str = "",retry_read: bool = False,+ read_subject: str | None = None,) -> str:env = Noneif token:@@ -246,11 +259,12 @@ class GitHub:if result.returncode != 0:detail = result.stderr.strip().splitlines() if output else []suffix = f": {detail[-1]}" if detail else ""+ operation = read_subject or " ".join(arguments[:3])if "HTTP 404" in result.stderr:raise GitHubNotFound(- f"GitHub object was not found ({' '.join(arguments[:3])}){suffix}"+ f"GitHub object was not found ({operation}){suffix}")- raise ReconciliationError(f"GitHub command failed ({' '.join(arguments[:3])}){suffix}")+ raise ReconciliationError(f"GitHub command failed ({operation}){suffix}")return result.stdout if output else ""def api(self, endpoint: str, *, token: str = "") -> dict[str, Any]:@@ -267,6 +281,7 @@ class GitHub:],token=token,retry_read=True,+ read_subject=api_read_subject(endpoint),))except json.JSONDecodeError as exc:@@ -276,7 +291,10 @@ class GitHub:return valuedef pages(self, endpoint: str, *, token: str = "") -> list[object]:- output = self._run(["api", "--paginate", endpoint], token=token, retry_read=True)+ output = self._run(+ ["api", "--paginate", endpoint], token=token, retry_read=True,+ read_subject=api_read_subject(endpoint),+ )decoder = json.JSONDecoder()value: list[object] = []offset = 0diff --git a/scripts/release_control/reconcile_release_convergence_test.py b/scripts/release_control/reconcile_release_convergence_test.pyindex 6661aa02f3..91ba3efeae 100644--- a/scripts/release_control/reconcile_release_convergence_test.py+++ b/scripts/release_control/reconcile_release_convergence_test.py@@ -105,6 +105,60 @@ class TransientReadTests(unittest.TestCase):sleep.assert_not_called()+class FailedReadIdentityTests(unittest.TestCase):+ def test_header_bearing_api_failure_names_the_resource_without_retry(self):+ github = subject.GitHub("rcourtman/Pulse", "gh")+ endpoint = "repos/rcourtman/Pulse/actions/runs/37395942598"+ for status in (401, 403, 404):+ with self.subTest(status=status):+ result = subprocess.CompletedProcess([], 1, stdout="", stderr=f"HTTP {status}")+ with patch.object(subject.subprocess, "run", return_value=result) as command, patch("time.sleep") as sleep:+ with self.assertRaises(subject.ReconciliationError) as failure:+ github.api(endpoint)+ self.assertIn(f"GET {endpoint}", str(failure.exception))+ self.assertNotIn("Accept:", str(failure.exception))+ if status == 404:+ self.assertIsInstance(failure.exception, subject.GitHubNotFound)+ self.assertEqual(1, command.call_count)+ sleep.assert_not_called()++ def test_paginated_failure_omits_read_filters(self):+ github = subject.GitHub("rcourtman/Pulse", "gh")+ resource = "repos/rcourtman/Pulse/actions/workflows/release-convergence.yml/runs"+ result = subprocess.CompletedProcess([], 1, stdout="partial", stderr="HTTP 403")+ with patch.object(subject.subprocess, "run", return_value=result) as command, patch("time.sleep") as sleep:+ with self.assertRaises(subject.ReconciliationError) as failure:+ github.pages(resource + "?event=workflow_dispatch&private_filter=fixture-only")+ self.assertIn(f"GET {resource}", str(failure.exception))+ self.assertNotIn("private_filter", str(failure.exception))+ self.assertNotIn("fixture-only", str(failure.exception))+ self.assertEqual(1, command.call_count)+ sleep.assert_not_called()++ def test_unrecognised_resource_has_no_endpoint_disclosure(self):+ for endpoint in (+ "repos/another/private-repository/customer-fixture",+ "repos/rcourtman/Pulse/../customer-fixture",+ "repos/rcourtman/Pulse/" + "x" * 257,+ "repos/rcourtman/Pulse/customer-fixture\nforged diagnostic",+ ):+ with self.subTest(endpoint=endpoint):+ self.assertEqual("GitHub API read", subject.api_read_subject(endpoint))++ def test_discovery_stops_at_the_identified_failed_read_without_mutation(self):+ github = subject.GitHub("rcourtman/Pulse", "gh")+ results = [+ subprocess.CompletedProcess([], 0, stdout='{"default_branch": "main"}', stderr=""),+ subprocess.CompletedProcess([], 1, stdout="", stderr="HTTP 404"),+ ]+ with patch.object(subject.subprocess, "run", side_effect=results) as command, patch("time.sleep") as sleep:+ with self.assertRaisesRegex(subject.GitHubNotFound, "GET repos/rcourtman/Pulse/actions/workflows/release-convergence.yml"):+ subject.discover(github)+ self.assertEqual(2, command.call_count)+ self.assertTrue(all("POST" not in call.args[0] for call in command.call_args_list))+ sleep.assert_not_called()++class LatestFailedRunsTests(unittest.TestCase):def select(self, releases, runs):return subject.latest_failed_runs(