fix(release): let an older pending advance pass a stable page already ahead
The stable downloads page has a second writer on main: render-builds-table
in stable-release.yml's `complete` step renders a full-desktop release's
page before the ordered publication pass runs. If an older published
release's advance was still pending, that step put the page ahead of it.
The sequencer advances oldest first, so StableDownloads.prepare for the
older release then refused with "Refusing to move the stable downloads
page backward", on every rerun. Since the standalone CLI no longer
promotes stable, nothing could clear it.
Feed order is checked before promotion, so a page describing a newer
release can only be that renderer's. _check_stable_page_state now leaves
it as it is with a warning, as the renderer's own write_channel_page does,
and returns the bytes that should be live plus the write conditions (None:
no write). The older advance moves the feeds and the DMG alias, and the
public read-back checks the page that is actually live. The page is still
never moved backward.
In test_stable_promotion_rejects_stale_order_for_dmg_and_page, the
page-only-ahead case raised on 274bc33a78 and now promotes the older
release while leaving the newer page alone. stable-releases.md no longer
says the page changes only with promotion.
This commit is contained in:
@@ -552,17 +552,26 @@ def _check_stable_page_state(
|
||||
*,
|
||||
tag: str,
|
||||
page_bytes: bytes,
|
||||
) -> tuple[bool, dict[str, str]]:
|
||||
) -> tuple[bytes, dict[str, str] | None]:
|
||||
"""The page bytes that should be live after this promotion, and the conditions for writing
|
||||
them (None: nothing to write).
|
||||
|
||||
A page that already describes a newer release stays as it is. Feed order is checked before
|
||||
promotion, so that page can only come from render-builds-table's `complete` step rendering a
|
||||
newer release while this older advance was pending; refusing would wedge the sequencer, which
|
||||
advances oldest first."""
|
||||
from scripts.releases.downloads_page import supersedes
|
||||
|
||||
if existing is None:
|
||||
return True, {"If-None-Match": "*"}
|
||||
return page_bytes, {"If-None-Match": "*"}
|
||||
existing_bytes, etag = existing
|
||||
if not supersedes(existing_bytes.decode("utf-8", errors="replace"), tag):
|
||||
raise ValueError("Refusing to move the stable downloads page backward")
|
||||
print(f"::warning::the stable downloads page already describes a release newer than {tag}; "
|
||||
"leaving it unchanged")
|
||||
return existing_bytes, None
|
||||
if existing_bytes == page_bytes:
|
||||
return False, {}
|
||||
return True, {"If-Match": etag}
|
||||
return page_bytes, None
|
||||
return page_bytes, {"If-Match": etag}
|
||||
|
||||
|
||||
def _verify_public_head_size(public_base: str, key: str, expected_size: int) -> None:
|
||||
@@ -583,10 +592,10 @@ class StableDownloads:
|
||||
"""The stable macOS DMG alias and downloads page for one accepted candidate.
|
||||
|
||||
``prepare`` runs every check (the DMG receipt, its source object and the single-copy limit,
|
||||
the order against the live alias and page) before any feed moves. ``promote`` calls ``publish_dmg`` right after the macOS
|
||||
feed, so a failed copy leaves the Windows and Termux pointers on the previous release, and
|
||||
``publish_page`` after every feed pointer, so a failed feed write leaves the page there too.
|
||||
Each write is read back through the public origin."""
|
||||
the order against the live alias and page) before any feed moves. ``promote`` calls
|
||||
``publish_dmg`` right after the macOS feed, so a failed copy leaves the Windows and Termux
|
||||
pointers on the previous release, and ``publish_page`` after every feed pointer, so a failed
|
||||
feed write leaves the page there too. Each object is read back through the public origin."""
|
||||
|
||||
tag: str
|
||||
public_base: str
|
||||
@@ -597,8 +606,7 @@ class StableDownloads:
|
||||
dmg_sha256: str
|
||||
dmg_needs_copy: bool
|
||||
page_bytes: bytes = field(repr=False)
|
||||
page_needs_write: bool
|
||||
page_conditions: dict[str, str]
|
||||
page_conditions: dict[str, str] | None
|
||||
|
||||
@classmethod
|
||||
def prepare(cls, manifest: dict, public_base: str) -> StableDownloads:
|
||||
@@ -618,7 +626,7 @@ class StableDownloads:
|
||||
expected_size=dmg_item["size"],
|
||||
expected_sha256=dmg_item["sha256"],
|
||||
)
|
||||
page_needs_write, page_conditions = _check_stable_page_state(
|
||||
page_bytes, page_conditions = _check_stable_page_state(
|
||||
R2ChannelStore(creds, base, bucket).get(r2.channel_page_key_for("stable")),
|
||||
tag=manifest["tag"],
|
||||
page_bytes=page_bytes,
|
||||
@@ -626,8 +634,7 @@ class StableDownloads:
|
||||
return cls(
|
||||
tag=manifest["tag"], public_base=public_base, creds=creds, base=base, bucket=bucket,
|
||||
source_dmg=source_dmg, dmg_sha256=dmg_item["sha256"],
|
||||
dmg_needs_copy=dmg_needs_copy, page_bytes=page_bytes, page_needs_write=page_needs_write,
|
||||
page_conditions=page_conditions,
|
||||
dmg_needs_copy=dmg_needs_copy, page_bytes=page_bytes, page_conditions=page_conditions,
|
||||
)
|
||||
|
||||
def publish_dmg(self) -> None:
|
||||
@@ -647,7 +654,7 @@ class StableDownloads:
|
||||
from scripts.releases import r2
|
||||
|
||||
page_key = r2.channel_page_key_for("stable")
|
||||
if self.page_needs_write:
|
||||
if self.page_conditions is not None:
|
||||
r2.put_object(
|
||||
self.creds, self.base, self.bucket, page_key, self.page_bytes, r2.amz_timestamp(),
|
||||
"text/html; charset=utf-8", self.page_conditions,
|
||||
|
||||
@@ -256,15 +256,21 @@ def test_stable_promotion_rejects_stale_order_for_dmg_and_page(
|
||||
assert r2_server.store[STABLE_DMG_KEY][0] == newer_dmg
|
||||
assert r2_server.store[STABLE_PAGE_KEY][0] == newer_page
|
||||
|
||||
# Only the page ahead is the state render-builds-table's `complete` step leaves when it
|
||||
# renders a newer release while an older advance is still pending. The sequencer advances
|
||||
# oldest first, so the older promotion must land and leave that page alone, not wedge.
|
||||
del r2_server.store[STABLE_DMG_KEY]
|
||||
r2_server.metadata.pop(STABLE_DMG_KEY, None)
|
||||
r2_server.requests.clear()
|
||||
with pytest.raises(ValueError, match="backward"):
|
||||
artifacts.promote(older, tmp_path / "promote-older-page-guard", https_origin.base)
|
||||
assert not any(method == "PUT" for method, _, _ in r2_server.requests)
|
||||
artifacts.promote(older, tmp_path / "promote-older-page-ahead", https_origin.base)
|
||||
assert r2_server.store[STABLE_DMG_KEY][0] == _older_dmg
|
||||
assert r2_server.store[STABLE_PAGE_KEY][0] == newer_page
|
||||
assert not any(method == "PUT" and path == f"/hermes-releases/{STABLE_PAGE_KEY}"
|
||||
for method, path, _ in r2_server.requests)
|
||||
|
||||
artifacts.promote(newer, tmp_path / "restore-newer", https_origin.base)
|
||||
assert r2_server.store[STABLE_DMG_KEY][0] == newer_dmg
|
||||
assert r2_server.store[STABLE_PAGE_KEY][0] == newer_page
|
||||
different_same_ver, _ = _stage_stable_release(
|
||||
tmp_path,
|
||||
r2_server,
|
||||
|
||||
@@ -78,8 +78,11 @@ because it would skip the published-release check and run outside the
|
||||
serialized `stable-release` group. Repair a partial stable publication by
|
||||
running Stable Release Publication again. A rerun repeats only an unfinished
|
||||
advance (a head, candidate pointer or Docker alias still behind); it never
|
||||
re-promotes a release that finished, so the unversioned DMG and the downloads
|
||||
page change only with a full-desktop promotion.
|
||||
re-promotes a release that finished, so it never backfills the unversioned DMG
|
||||
or the downloads page. The DMG changes only with a full-desktop promotion. The
|
||||
page also changes when `complete` renders a full-desktop release, which can put
|
||||
it ahead of an older advance still pending; that promotion then leaves the
|
||||
newer page as it is.
|
||||
|
||||
## Run, publish, or abandon a stable release
|
||||
|
||||
|
||||
Reference in New Issue
Block a user