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.

Accept release-dispatch refs as post-merge snapshot dispatches

rcourtman879de51e285c
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 3882e92747..0439dabb48 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -1276,7 +1276,14 @@ preparation PR's qualified head stays fixed on `release-candidate/<packet>`
while its governed source branch continues receiving work. Dispatch verifies
that the canonical PR merged into the version's governed source line, that its
head and ref match the admitted snapshot, and that its merge remains in that
-line's published history. Qualification, workflow execution, compiler dispatch
+line's published history. A dispatch may also run from
+`release-dispatch/<packet>`, a ref reserved for creation after merge. It must
+identify a merged PR whose head is `release-candidate/<packet>` at the
+dispatched commit, so release secrets can be confined to refs that exist only
+after merge while unmerged `release-candidate/*` heads stay outside them. The
+snapshot check validates identity only; restricting who can create or move
+`release-dispatch/*` refs belongs to a repository ruleset, and until that
+ruleset is active the namespace carries no extra trust. Qualification, workflow execution, compiler dispatch
and published artifacts bind to that head, not a later merge or branch tip.
The source workflow must implement the snapshot input and provenance contract
before the release train spends an exact qualification run on it. Later
diff --git a/scripts/release_control/release_snapshot.py b/scripts/release_control/release_snapshot.py
index 5d1f359fc2..153deea0d8 100644
--- a/scripts/release_control/release_snapshot.py
+++ b/scripts/release_control/release_snapshot.py
@@ -12,19 +12,33 @@ import subprocess
SHA = re.compile(r"[0-9a-f]{40}")
SNAPSHOT_REF = re.compile(r"release-candidate/[0-9A-Za-z._-]+")
+# Post-merge dispatch refs. Only the release dispatcher can create or move
+# them, so the release environment can admit them while unmerged
+# release-candidate heads stay outside it. Each mirrors its PR's head name.
+DISPATCH_REF = re.compile(r"release-dispatch/([0-9A-Za-z._-]+)")
SOURCE_BRANCH = re.compile(r"main|release/v[0-9]+\.[0-9]+")
+def snapshot_head(branch: str) -> str:
+ """Return the PR head branch a snapshot dispatch branch must identify."""
+ dispatch = DISPATCH_REF.fullmatch(branch)
+ if dispatch:
+ return "release-candidate/" + dispatch.group(1)
+ if SNAPSHOT_REF.fullmatch(branch):
+ return branch
+ raise ValueError("release dispatch is not a reserved snapshot ref")
+
+
def source_branch(ref: str, requested: str, pull_request: str) -> str:
if not ref.startswith("refs/heads/"):
raise ValueError("release dispatch must name a branch ref")
branch = ref.removeprefix("refs/heads/")
- if SNAPSHOT_REF.fullmatch(branch):
+ if SNAPSHOT_REF.fullmatch(branch) or DISPATCH_REF.fullmatch(branch):
if not SOURCE_BRANCH.fullmatch(requested) or not re.fullmatch(r"[1-9][0-9]*", pull_request):
raise ValueError("snapshot dispatch requires its governed source branch and merged pull request")
return requested
if requested or pull_request:
- raise ValueError("snapshot provenance inputs require a reserved release-candidate ref")
+ raise ValueError("snapshot provenance inputs require a reserved release-candidate or release-dispatch ref")
if not SOURCE_BRANCH.fullmatch(branch):
raise ValueError("release dispatch is outside a governed source branch")
return branch
@@ -36,7 +50,7 @@ def reviewed_merge(pr: dict, *, repository: str, ref: str, branch: str, sha: str
head, base = pr.get("head", {}), pr.get("base", {})
if pr.get("merged") is not True or pr.get("state") != "closed":
raise ValueError("release snapshot pull request is not merged")
- if head.get("sha") != sha or head.get("ref") != ref.removeprefix("refs/heads/"):
+ if head.get("sha") != sha or head.get("ref") != snapshot_head(ref.removeprefix("refs/heads/")):
raise ValueError("pull request does not identify the dispatched snapshot")
if base.get("ref") != branch:
raise ValueError("pull request belongs to another release line")
diff --git a/scripts/release_control/release_snapshot_test.py b/scripts/release_control/release_snapshot_test.py
index cf50930f01..aeabf55b67 100644
--- a/scripts/release_control/release_snapshot_test.py
+++ b/scripts/release_control/release_snapshot_test.py
@@ -47,9 +47,34 @@ class SnapshotIdentityTest(unittest.TestCase):
with self.assertRaises(ValueError):
self.verify(pr)
+ def test_post_merge_ref_identifies_its_merged_snapshot_by_head_name(self):
+ dispatch = 'refs/heads/release-dispatch/packet-1'
+ self.assertEqual('release/v6.4', snapshot.source_branch(dispatch, 'release/v6.4', '42'))
+ self.assertEqual(self.merge, snapshot.reviewed_merge(
+ self.pr, repository='rcourtman/Pulse', ref=dispatch, branch='release/v6.4', sha=self.sha))
+ for head_ref in ('release-candidate/other', 'release-dispatch/packet-1', 'maintainer/packet-1'):
+ with self.subTest(head_ref=head_ref), self.assertRaises(ValueError):
+ pr = deepcopy(self.pr)
+ pr['head']['ref'] = head_ref
+ snapshot.reviewed_merge(pr, repository='rcourtman/Pulse', ref=dispatch,
+ branch='release/v6.4', sha=self.sha)
+
+ def test_snapshot_head_admits_only_reserved_snapshot_names(self):
+ self.assertEqual('release-candidate/v6.6.1-rc.1-20261101T000000Z',
+ snapshot.snapshot_head('release-dispatch/v6.6.1-rc.1-20261101T000000Z'))
+ self.assertEqual('release-candidate/packet-1', snapshot.snapshot_head('release-candidate/packet-1'))
+ for branch in ('release-dispatch/', 'release-dispatch/a/b', 'release-dispatch/a b',
+ 'maintainer/packet-1', 'main', 'xrelease-dispatch/packet-1'):
+ with self.subTest(branch=branch), self.assertRaises(ValueError):
+ snapshot.snapshot_head(branch)
+
def test_unbound_dispatch_inputs_are_rejected(self):
+ dispatch = 'refs/heads/release-dispatch/packet-1'
for args in [(self.ref, '', '42'), (self.ref, 'main', ''),
(self.ref, 'feature/other', '42'), (self.ref, 'main', '../42'),
+ (dispatch, '', '42'), (dispatch, 'main', ''), (dispatch, 'feature/other', '42'),
+ ('refs/heads/release-dispatch/a/b', 'main', '42'),
+ ('refs/tags/release-dispatch/packet-1', 'main', '42'),
('refs/heads/main', 'main', '42'), ('refs/tags/v6.4.4-beta.1', '', '')]:
with self.subTest(args=args), self.assertRaises(ValueError):
snapshot.source_branch(*args)
@@ -64,9 +89,14 @@ class SnapshotIdentityTest(unittest.TestCase):
snapshot.check_workflow(old)
def test_workflow_verifies_ancestry_without_requiring_current_tip(self):
+ for ref in (self.ref, 'refs/heads/release-dispatch/packet-1'):
+ with self.subTest(ref=ref):
+ self.verify_main(ref)
+
+ def verify_main(self, ref):
with tempfile.TemporaryDirectory() as raw:
output = Path(raw) / 'output'
- env = {'GITHUB_REF': self.ref, 'RELEASE_SOURCE_BRANCH': 'release/v6.4',
+ env = {'GITHUB_REF': ref, 'RELEASE_SOURCE_BRANCH': 'release/v6.4',
'RELEASE_PULL_REQUEST': '42', 'GITHUB_REPOSITORY': 'rcourtman/Pulse',
'GITHUB_SHA': self.sha, 'GITHUB_WORKFLOW_SHA': self.sha,
'GITHUB_OUTPUT': str(output)}