Skip to content

fix(publish-to-r2): upload payloads before metadata, with retries - #85

Merged
bketelsen merged 4 commits into
mainfrom
fix/publish-r2-ordered-upload
Nov 2, 2026
Merged

bketelsen merged 4 commits into
mainfrom
fix/publish-r2-ordered-upload

Conversation

@frostyard-machines

Copy link
Copy Markdown

Fixes #84.

Problem

publish-to-r2 uploaded ./repo with 1 parallel aws s3 sync. Metadata and payloads raced. On 2026-11-02 (snosi run 41384581449) 1 R2 InvalidPart left ext/chatgpt/SHA256SUMS listing a +r1 payload that returns 404.

Change

scripts/upload-to-r2.sh (called by the action's upload step) runs:

  1. payloads only (--exclude '*' + includes for *.raw*, *.apk, *.pkg.tar* incl. .sig, *.bottle.tar*), retried;
  2. verify: same filters, --dryrun --size-only; any upload: line fails the step before metadata;
  3. metadata (everything that is not a payload or an index), retried;
  4. directory indexes (index, index.html at any depth) last, retried.

Retries: UPLOAD_ATTEMPTS (4), wait 15s * N; AWS_RETRY_MODE=standard, AWS_MAX_ATTEMPTS=10 unless set. Bucket/prefix now reach the step through env:.

Invariant: live metadata never references a payload that is not in the bucket. Residual (documented in ADR-0017): SHA256SUMS and SHA256SUMS.gpg are still 2 PUTs, so a short signature mismatch is possible; callers must still serialize runs.

Tests

  • internal/releaseasset/upload_order_test.go: a fake aws with S3 filter semantics; order, per-format classification, permanent failure (old metadata untouched), transient retry, silent-skip caught by verify, action contract.
  • Manual: the script ran against real aws-cli 1.46 + a local moto S3 server: the 4 calls upload exactly payloads → metadata → indexes; a rerun uploads nothing; a skipped payload fails phase 2 and the old SHA256SUMS stays.
  • make build fmt lint test-unit, shellcheck, node scripts/check-docs.mjs: green.

Migration

No input change. A consumer gets it by moving the action pin and repogen-version/repogen-commit together to the release that contains it. Only consumer: frostyard/snosi build.yml (pin c3c9f63, v0.7.0). The release is Brian's.

Docs: ADR-0017 (Proposed), docs/design/ci-cd.md, docs/specs/generators.md, README, AGENTS.md (stale snosi pin fixed).

One parallel aws s3 sync let SHA256SUMS go live before its payload. A
failed R2 multipart upload (snosi run 41384581449) left
ext/chatgpt/SHA256SUMS listing a file that returns 404.

scripts/upload-to-r2.sh now uploads payloads, verifies them with a
--dryrun --size-only sync, then uploads metadata, then directory
indexes. Each upload phase retries; AWS_RETRY_MODE=standard and
AWS_MAX_ATTEMPTS=10 by default. ADR-0017 records the decision.
AGENTS.md: correct the stale snosi pin (now c3c9f63, v0.7.0).
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…payload names

Cross-review: *.pkg.tar.* and *.bottle.tar* also matched files under a
directory named like a payload (ext/foo.pkg.tar.x/SHA256SUMS), so that
manifest went up in phase 1 beside its payload. Patterns are now
end-anchored, and phase 0 refuses a payload-like base name that no
pattern covers before any upload. The README manual example now stops
on a failed payload upload (&&).
… out of it

Re-review: the guard refused generated sysext transfer files such as
foo.pkg.tar.x.transfer. It now checks only the 2 detector shapes that
are not end-anchored (.pkg.tar., .bottle.tar) and skips *.transfer.
Tests include the transfer files and prove phase 1 ran.
…fer from phase 0

Re-review: any *.transfer name was exempt, so a bottle named
*.bottle.tar.gz.transfer could go up beside its formula. Only the
generated sysext transfer path is exempt now; a test proves the bottle
case is refused before any sync.
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 2, 2026
@bketelsen
bketelsen merged commit fc6740a into main Nov 2, 2026
3 checks passed
@frostyard-machines
frostyard-machines deleted the fix/publish-r2-ordered-upload branch November 2, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

publish-to-r2: a failed payload upload leaves SHA256SUMS listing a missing file

2 participants