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.

fix(delivery): distinguish dry-run proposals from submitted retries

pulse-triage[bot]6ecee4b4c4ee
diff --git a/scripts/release_control/reconcile_release_convergence.py b/scripts/release_control/reconcile_release_convergence.py
index d0828ff2e8..252d61d02a 100644
--- a/scripts/release_control/reconcile_release_convergence.py
+++ b/scripts/release_control/reconcile_release_convergence.py
@@ -272,10 +272,11 @@ class GitHub:
raise ReconciliationError(f"GitHub returned no pages for {endpoint}")
return value
- def post(self, endpoint: str, payload: dict[str, Any] | None = None) -> None:
+ def post(self, endpoint: str, payload: dict[str, Any] | None = None) -> bool:
+ """Return whether a mutation was submitted; dry runs never submit."""
if not self.mutate:
print(f"DRY RUN: POST {endpoint}")
- return
+ return False
arguments = [
"api",
"--method",
@@ -299,8 +300,9 @@ class GitHub:
detail = result.stderr.strip().splitlines()
suffix = f": {detail[-1]}" if detail else ""
raise ReconciliationError(f"GitHub mutation failed for {endpoint}{suffix}")
- return
+ return True
self._run(arguments)
+ return True
def download_marker(self, tag: str, directory: Path) -> dict[str, Any]:
self._run(
@@ -550,8 +552,9 @@ def reconcile(github: GitHub, run_id: int, max_attempts: int) -> None:
if source.get("status") != "completed" and positive_int(
run.get("run_attempt"), "run attempt"
) < 50:
- github.post(f"repos/{repository}/actions/runs/{run_id}/rerun")
- print(f"Renewed pre-commit convergence owner {run_id} for active source {source_run_id}.")
+ submitted = github.post(f"repos/{repository}/actions/runs/{run_id}/rerun")
+ action = "Renewed" if submitted else "DRY RUN: Would renew"
+ print(f"{action} pre-commit convergence owner {run_id} for active source {source_run_id}.")
return
print(f"{tag} has no immutable activation commit; no convergence retry was dispatched.")
return
@@ -598,8 +601,9 @@ def reconcile(github: GitHub, run_id: int, max_attempts: int) -> None:
"no unchanged-control retry was dispatched."
)
return
- github.post(f"repos/{repository}/actions/runs/{run_id}/rerun")
- print(f"Re-ran current-control convergence {run_id} for committed {tag}.")
+ submitted = github.post(f"repos/{repository}/actions/runs/{run_id}/rerun")
+ action = "Re-ran" if submitted else "DRY RUN: Would re-run"
+ print(f"{action} current-control convergence {run_id} for committed {tag}.")
return
prerelease = release.get("prerelease")
@@ -619,12 +623,13 @@ def reconcile(github: GitHub, run_id: int, max_attempts: int) -> None:
"source_release_run_id": marker["source_release_run_id"],
},
}
- github.post(
+ submitted = github.post(
f"repos/{repository}/actions/workflows/release-convergence.yml/dispatches",
payload,
)
+ action = "Dispatched" if submitted else "DRY RUN: Would dispatch"
print(
- f"Dispatched fresh convergence controls after observing {default_commit} for committed {tag}; "
+ f"{action} fresh convergence controls after observing {default_commit} for committed {tag}; "
f"the failed run used {run.get('head_sha')}."
)
diff --git a/scripts/release_control/reconcile_release_convergence_test.py b/scripts/release_control/reconcile_release_convergence_test.py
index db0a09beb5..56f6aadfaf 100644
--- a/scripts/release_control/reconcile_release_convergence_test.py
+++ b/scripts/release_control/reconcile_release_convergence_test.py
@@ -249,6 +249,7 @@ class FakeGitHub:
def post(self, endpoint, payload=None):
self.posts.append((endpoint, payload))
+ return True
def unchanged_credential_containment_block(self, run_id):
self.containment_probe = run_id
@@ -460,6 +461,39 @@ class CredentialContainmentTests(unittest.TestCase):
class ReconciliationTests(unittest.TestCase):
+ def test_post_reports_submission_only_after_success(self):
+ for payload in (None, {"ref": "main"}):
+ for code in (0, 1):
+ with self.subTest(payload=payload, code=code):
+ github = subject.GitHub("rcourtman/Pulse", "gh")
+ result = subprocess.CompletedProcess([], code, stdout="", stderr="failed" if code else "")
+ with patch.object(subject.subprocess, "run", return_value=result) as command:
+ if code:
+ with self.assertRaises(subject.ReconciliationError):
+ github.post("repos/rcourtman/Pulse/test", payload)
+ else:
+ self.assertIs(True, github.post("repos/rcourtman/Pulse/test", payload))
+ command.assert_called_once()
+
+ def test_dry_run_receipts_never_claim_a_mutation(self):
+ cases = [
+ ({}, "Would dispatch", "Dispatched"),
+ ({"current_controls": True}, "Would re-run", "Re-ran"),
+ ({"committed": False}, "Would renew", "Renewed"),
+ ]
+ for options, expected, forbidden in cases:
+ with self.subTest(options=options):
+ github = FakeGitHub(**options)
+ transport = subject.GitHub(github.repository, "gh", mutate=False)
+ github.post = transport.post
+ output = io.StringIO()
+ with patch.object(subject.subprocess, "run") as command, contextlib.redirect_stdout(output):
+ subject.reconcile(github, github.run_id, 5)
+ command.assert_not_called()
+ self.assertIn("DRY RUN: " + expected, output.getvalue())
+ self.assertNotIn(forbidden, output.getvalue())
+ self.assertEqual([], github.posts)
+
def test_stale_failed_run_dispatches_current_controls_with_bound_inputs(self):
github = FakeGitHub()
subject.reconcile(github, github.run_id, 5)