Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(ci): retry attestation lookups the service cannot answer in release smoke (#459)

Ruben Lütkec8922a17c937
diff --git a/docs/ci-pipeline.md b/docs/ci-pipeline.md
index 63db2aa100..4a3335dbc5 100644
--- a/docs/ci-pipeline.md
+++ b/docs/ci-pipeline.md
@@ -222,7 +222,10 @@ A release happens **only** when the maintainer asks for one.
`install-verify.ps1` in dry-run, no-launch mode on Linux, Windows and
macOS (`release-wrapper-smoke.yml`, which `installer-smoke.yml` also runs on
Linux). Release cut calls it after publishing and requires attestations; a
- release published with `GITHUB_TOKEN` fires no `release` event. Re-check any
+ release published with `GITHUB_TOKEN` fires no `release` event. An
+ attestation lookup that keeps getting a server error (HTTP 5xx, retried
+ twice) fails only when attestations are required; otherwise it is a
+ warning, like a missing attestation on an older release. Re-check any
tag with `gh workflow run release-smoke.yml -f tag=vX.Y.Z`.
### When a release is bad: roll forward
diff --git a/scripts/ci/release_assets.py b/scripts/ci/release_assets.py
index 7de3cebe7a..5344b3c4e7 100644
--- a/scripts/ci/release_assets.py
+++ b/scripts/ci/release_assets.py
@@ -440,18 +440,36 @@ def platform_installers(platform: str, manifest: dict[str, str]) -> list[str]:
return names
+#: Pauses before retrying an attestation lookup the service could not answer.
+ATTESTATION_RETRY_DELAYS = (5.0, 15.0)
+_SERVER_ERROR = re.compile(r"\(HTTP 5\d\d\)")
+
+
def attestation_state(repo: str, tag: str, path: Path, digest: str) -> str:
- """``verified``, ``absent`` or ``failed`` for one downloaded installer.
+ """``verified``, ``absent``, ``unavailable`` or ``failed`` for one installer.
Only the tag build of desktop-installers.yml may vouch for a native
installer, so the verification pins both the signing workflow and the ref.
+ ``unavailable`` means GitHub's attestation service kept answering with a
+ server error, so nothing is known about the installer's provenance.
"""
endpoint = f"repos/{repo}/attestations/sha256:{digest}"
- lookup = run_command(["gh", "api", endpoint, "--jq", ".attestations | length"], check=False)
+ command = ["gh", "api", endpoint, "--jq", ".attestations | length"]
+ lookup = run_command(command, check=False)
+ for delay in ATTESTATION_RETRY_DELAYS:
+ if lookup.returncode == 0 or not _SERVER_ERROR.search(lookup.stderr):
+ break
+ print(f"[release] attestation service error for {path.name}; retrying in {delay:g}s")
+ time.sleep(delay)
+ lookup = run_command(command, check=False)
if lookup.returncode != 0:
if "HTTP 404" in lookup.stderr:
return "absent"
- print(f"::error::attestation lookup failed for {path.name}: {lookup.stderr.strip()}")
+ detail = lookup.stderr.strip()
+ if _SERVER_ERROR.search(lookup.stderr):
+ print(f"::warning::attestation service unavailable for {path.name}: {detail}")
+ return "unavailable"
+ print(f"::error::attestation lookup failed for {path.name}: {detail}")
return "failed"
if lookup.stdout.strip() in {"", "0"}:
return "absent"
@@ -496,7 +514,9 @@ def platform_errors(
errors.append(f"downloaded {name} does not match installers-SHA256SUMS.txt")
continue
state = attestation_state(repo, tag, path, digest)
- if state == "failed" or (state == "absent" and require_attestation):
+ # Without required provenance (releases built before attestations), an
+ # unknown answer is no worse than a missing attestation: report, pass.
+ if state == "failed" or (state in {"absent", "unavailable"} and require_attestation):
errors.append(f"build provenance attestation {state}: {name}")
elif state == "absent":
print(f"::notice::{name} has no build provenance attestation (older build)")
diff --git a/tests/unit/ci/test_release_smoke.py b/tests/unit/ci/test_release_smoke.py
index eae2f9da46..0ea0853355 100644
--- a/tests/unit/ci/test_release_smoke.py
+++ b/tests/unit/ci/test_release_smoke.py
@@ -26,7 +26,7 @@ def workflows() -> dict[str, dict]:
class FakePublishedRelease:
"""In-memory published release; any write command fails the test."""
- def __init__(self, *, attested=0, attestation_ok=True, draft=False):
+ def __init__(self, *, attested=0, attestation_ok=True, draft=False, outages=0):
self.payloads = {
"PersonalJarvis-Linux-x86_64.AppImage": b"appimage",
"personal-jarvis_1.2.3_amd64.deb": b"deb",
@@ -39,6 +39,8 @@ class FakePublishedRelease:
self.attested = attested
self.attestation_ok = attestation_ok
self.draft = draft
+ #: Attestation lookups answered with a server error before a real answer.
+ self.outages = outages
self.commands = []
def command(self, args, **kwargs):
@@ -52,6 +54,11 @@ class FakePublishedRelease:
(folder / name).write_bytes(self.payloads[name])
return subprocess.CompletedProcess(args, 0, "", "")
if args[:2] == ["gh", "api"] and "/attestations/sha256:" in args[2]:
+ if self.outages:
+ self.outages -= 1
+ return subprocess.CompletedProcess(
+ args, 1, "", "gh: trust-metadata-api service unavailable (HTTP 503)"
+ )
if not self.attested:
return subprocess.CompletedProcess(args, 1, "", "gh: Not Found (HTTP 404)")
return subprocess.CompletedProcess(args, 0, f"{self.attested}\n", "")
@@ -115,6 +122,34 @@ def test_older_unattested_builds_pass_unless_provenance_is_required(monkeypatch,
assert errors == []
+def test_a_brief_attestation_service_outage_is_retried(monkeypatch, tmp_path):
+ monkeypatch.setattr(release_assets, "ATTESTATION_RETRY_DELAYS", (0, 0))
+ fake = FakePublishedRelease(attested=1, outages=2)
+ fake.install(monkeypatch)
+ errors = release_assets.platform_errors(
+ REPO, TAG, "windows", tmp_path, require_attestation=True
+ )
+ assert errors == []
+ assert any(c[:3] == ["gh", "attestation", "verify"] for c in fake.commands)
+
+
[email protected]("require,failing", [(False, False), (True, True)])
+def test_a_lasting_attestation_outage_fails_only_required_provenance(
+ monkeypatch, tmp_path, require, failing
+):
+ monkeypatch.setattr(release_assets, "ATTESTATION_RETRY_DELAYS", (0, 0))
+ fake = FakePublishedRelease(attested=1, outages=99)
+ fake.install(monkeypatch)
+ errors = release_assets.platform_errors(
+ REPO, TAG, "windows", tmp_path, require_attestation=require
+ )
+ lookups = [c for c in fake.commands if c[:2] == ["gh", "api"]]
+ assert len(lookups) == 3
+ assert bool(errors) is failing
+ if failing:
+ assert errors == ["build provenance attestation unavailable: PersonalJarvis-Setup-x64.exe"]
+
+
def test_smoke_refuses_a_draft_without_touching_it(monkeypatch):
fake = FakePublishedRelease(draft=True)
fake.install(monkeypatch)