nightly: recheck signer admission after enabling, and catch a missed page of running jobs

CodeRabbit found two more issues; both are fixed on this update. The advance now calls check_admission after the enable write, so a rollback that revoked trust during that write cannot leave a signer active but unadmitted, and the PARTIAL message names admission too. The rollback test now fails when a page of running jobs is missed, which is the case it was supposed to catch. 833 applicable offline tests pass.
This commit is contained in:
skylartaylor committed 2026-11-26 21:51:30 +01:00
1 parent 2f4ec5ebbc
commit f09e009e66
2 files changed
+17 -7

No files matched your search

+5 -3
View File
@@ -718,11 +718,13 @@ def advance(app, sha, apply, enable=False):
else:
try:
gh("PUT", f"repos/{ORG}/{app}/actions/workflows/nightly-sign.yml/enable", write=True, apply=apply)
if apply and (workflow_state(app) != "active" or gh("GET", path)["object"]["sha"] != sha):
raise Refuse("workflow activation or reviewed head did not read back exactly")
if apply:
if workflow_state(app) != "active" or gh("GET", path)["object"]["sha"] != sha:
raise Refuse("workflow activation or reviewed head did not read back exactly")
check_admission(app) # Rollback may have revoked trust during the enable write.
except (Refuse, KeyError, TypeError, ValueError, AttributeError) as error:
containment = disable_after_uncertain_enable(app) if apply else "no runtime write attempted"
raise Refuse(f"PARTIAL: enable attempted; activation and reviewed head are not verified: {error}; "
raise Refuse(f"PARTIAL: enable attempted; activation, reviewed head or signer admission is not verified: {error}; "
f"{containment}; an intervening dispatch or credential-bearing run remains possible; run rollback")
elif resume:
print(f" exact {REF} already at reviewed {sha[:10]}; workflow remains {state}")
+12 -4
View File
@@ -772,7 +772,7 @@ class AdvanceTests(unittest.TestCase):
self.assertEqual(fake.writes, [])
def test_uncertain_enable_attempts_disable_and_reports_remaining_run_risk(self):
for fault in ("head drift", "head unreadable", "activation response lost"):
for fault in ("head drift", "head unreadable", "activation response lost", "admission revoked"):
fake = self.fake(branch="b" * 40, workflow_state="disabled_manually")
attempted = False
def api(method, path, *args, **kwargs):
@@ -784,13 +784,17 @@ class AdvanceTests(unittest.TestCase):
fake.branch = MAIN
if fault == "activation response lost":
raise s.Refuse("HTTP 502")
if fault == "admission revoked":
fake.policies = [("release", 1)]
return result
if attempted and fault == "head unreadable" and path.endswith("/git/ref/heads/nightly-signer"):
return {}
return fake(method, path, *args, **kwargs)
with self.subTest(fault=fault), patch.object(s, "gh", api), quiet():
with self.assertRaisesRegex(s.Refuse, "PARTIAL.*disabled_manually.*intervening dispatch.*run rollback"):
with self.assertRaisesRegex(s.Refuse, "PARTIAL.*disabled_manually.*intervening dispatch.*run rollback") as refusal:
s.advance("gridcraft", "b" * 40, True, enable=True)
if fault == "admission revoked":
self.assertIn("does not admit exactly", str(refusal.exception))
self.assertEqual(fake.workflow_state, "disabled_manually")
self.assertTrue(any(path.endswith("/disable") for _, path, _ in fake.writes))
@@ -943,14 +947,18 @@ class RollbackTests(unittest.TestCase):
return {"workflow_runs": []}
if fault == "malformed row":
return {"workflow_runs": [{"id": 5, "status": "queued"}, {"id": "untrusted", "status": "queued"}]}
if "status=in_progress" in path or (fault == "later page" and "status=queued" in path and "&page=2" in path):
if fault == "later page" and "status=queued" in path and "&page=2" in path:
return {}
if "status=in_progress" in path and (fault != "later page" or inventories > 1):
if fault == "transport":
raise s.Refuse("HTTP 503")
return {}
return fake(method, path, *args, **kwargs)
with self.subTest(fault=fault), patch.object(s, "gh", api), quiet():
with self.assertRaisesRegex(s.Refuse, "PARTIAL.*listing signer runs.*known runs not verified stopped"):
with self.assertRaisesRegex(s.Refuse, "PARTIAL.*listing signer runs.*known runs not verified stopped") as refusal:
s.rollback("gridcraft", True, wait=lambda _: None)
if fault == "later page":
self.assertIn("queued page 2: UNVERIFIED", str(refusal.exception))
self.assertEqual(fake.workflow_state, "disabled_manually")
self.assertEqual(set(fake.cancels), set(ids))
self.assertTrue(all(count == s.MAX_CANCEL_ROUNDS for count in fake.cancels.values()))