Skip to content

Mirror: incremental pass for new registry releases, fail fast on a 403, ETag-guarded state DB - #2066

Merged
zackees merged 3 commits into
mainfrom
feat/mirror-incremental-2040
Nov 17, 2026
Merged

zackees merged 3 commits into
mainfrom
feat/mirror-incremental-2040

Conversation

@zackees

@zackees zackees commented Nov 17, 2026

Copy link
Copy Markdown
Member

Why

#2040 item 4: nothing picked up new registry releases. mirror.py catalog re-read versions only for packages it had never seen. A new release of a known package, like FastLED 3.10.9, was never queued, so #2034 had to mirror it by hand.

What changed

  • Incremental catalog (ci/mirror/mirror.py)
    • The registry search is paged newest-updated first (sort=updated, checked against the live API).
    • It stops at a watermark, stored in a new meta table, less a 6 h overlap.
    • Every package updated since then has its versions read again.
    • A scan records a new watermark only if it covered everything since the old one.
  • ci/mirror/update.py runs the incremental pass from one machine, with no droplet. Steps:
    1. Download the bucket DB and its ETag.
    2. Catalog, or with --package owner/type/name, refresh only the named packages and leave the watermark alone.
    3. Print the exact queue. --dry-run stops here.
    4. Refuse a queue over --max-bytes.
    5. Back up the DB server-side (CopySourceIfMatch), transfer the queue, and upload the DB with If-Match.
  • 403 fail-fast
    • Any registry 403 raises RegistryRefused. It is not retried.
    • The chunk's other downloads are cancelled, so their rows stay queued instead of becoming errors.
    • A registry_refused marker is written and the pass exits 3.
    • The droplet unit sets RestartPreventExitStatus=3, and rotate.py stops instead of rotating.
  • ETag-guarded state DB writes
    • rotate.py reads the DB and its ETag in one GET and uploads snapshots with If-Match (or If-None-Match: * when there was no DB).
    • A 412 raises ManifestConflict.
    • DO Spaces enforces it: a PUT with a wrong If-Match returned 412 and left the object unchanged.
  • Shard version stamping (ci/gen_mirror_manifest.py)
    • An unchanged shard keeps its text and version.
    • A new or changed shard gets --version, which defaults to today's UTC date.
    • An incremental pass therefore touches only the shards whose content changed. The client ignores the field.
  • gen_mirror_manifest.py --check now also fails when the state DB and the bucket disagree.

Data (third commit)

update.py --package earlephilhower/library/ESP8266Audio --package xylopyrographer/library/LiteLED

  • Dry run first. It listed exactly 2 files, 6321283 bytes, both absent from the bucket.
  • Backup. _state/manifest.db.bak-20261117T214822Z has the same sha256 as the previous DB (b3c91702…).
  • New DB. It has 29305 rows (29302 done). Its dump differs from the previous copy only by those 2 rows and the empty meta table.
  • Index. The regeneration changed only the two owner shards and their Index descriptors.
  • Checks. --check exits 0, and both public objects re-download with the registry's sha256.

Testing

  • ci/test_mirror_tool.py and ci/test_gen_mirror_manifest.py are both in the drift job; all 554 tests in that job pass locally. New tests cover:
    • a known package's new release being queued;
    • a rescan from the watermark;
    • a legacy DB with no watermark;
    • --package;
    • the watermark-advance rules;
    • 403 handling (not retried, chunk cancelled, marker, run refuses to start, unit flag);
    • conditional uploads and the backup;
    • update.py's guards;
    • per-shard stamping;
    • the state-DB --check.
  • The offline regeneration of the committed site/mirror/ with a different stamp is byte-identical.
  • Ruff C901 ≤ 10 and format pass.

Not in this PR (maintainer)

Part of #2040 (item 4)

An incremental pass that adds one release used to face a choice: restamp
all 8040 owner shards with a new version, or pass --version to keep the
old one, so the changed shard's version said nothing. Now a shard whose
components are unchanged keeps the text (and version) on disk, and a new
or changed shard gets --version, default today's UTC date. Regenerating
the committed site/mirror/ from its own data with a different stamp
reproduces it byte for byte. The client ignores the field; only
schema_version is checked.

--check also compares the state DB with the bucket: an object without a
done row, or a done row without an object, fails it. Before, --check
passed against the bucket while a regeneration stopped with "objects
have no system in the state db" (item 1).

Part of #2040 (item 4)
…rites

Incremental mode. `catalog` re-read versions only for packages it had
never seen, so a new release of a known package (FastLED 3.10.9, #2034)
was never queued. It now pages the registry search newest-updated first
(`sort=updated`) down to a watermark kept in a new `meta` table, less a
6 h overlap, and re-reads the versions of every package updated since.
A scan records a new watermark only if it covered everything since the
old one; a DB from before the watermark needs `--since` once.

ci/mirror/update.py runs that pass from one machine, with no droplet:
download the bucket DB and its ETag, catalog (or `--package` for named
packages only, watermark untouched), print the exact queue
(`--dry-run` stops there), refuse a queue over `--max-bytes`, back up
the DB server-side with CopySourceIfMatch, transfer, and upload the DB
with If-Match.

403 fail-fast. Any 403 from the registry raises RegistryRefused: the
download is not retried, the chunk's other downloads are cancelled so
their rows stay queued, a `registry_refused` marker is written and the
pass exits 3. `run` will not start while the marker exists, the droplet
unit sets RestartPreventExitStatus=3, and rotate.py snapshots, destroys
the droplet and exits 3 instead of rotating.

ETag guard. rotate.py reads the bucket DB and its ETag in one GET and
uploads snapshots with If-Match (If-None-Match when there was none); a
412 is a ManifestConflict. DO Spaces enforces it: a PUT with a wrong
If-Match got 412 PreconditionFailed and left the object unchanged.

To stay under C901 <= 10, `run`'s quota wait and catalog decision and
rotate's flag handling moved into helpers without behaviour change.

Part of #2040 (item 4)
Mirrored with `ci/mirror/update.py --package
earlephilhower/library/ESP8266Audio --package
xylopyrographer/library/LiteLED` after a dry run listed exactly these
two files (6321283 bytes), both absent from the bucket. The state DB was
backed up to _state/manifest.db.bak-20261117T214822Z first. The bucket
DB now has 29305 rows (29302 done). Its dump differs from the previous
copy only by the two rows and the new empty `meta` table.

Regenerated with ci/gen_mirror_manifest.py: only the two owner shards and
their Index descriptors changed, and only those shards were stamped
2026.11.17. `--check` passes, and both public objects re-download with
the registry's sha256.

Part of #2040 (item 4)
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zackees
zackees added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 5eaf469 Nov 17, 2026
29 checks passed
@zackees
zackees deleted the feat/mirror-incremental-2040 branch November 17, 2026 22:20
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant