Skip to content

ci: seed the Tier 2 apt archive on a schedule - #5527

Merged
zackees merged 1 commit into
masterfrom
feat/apt-cache-self-seed
Nov 23, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/apt-cache-self-seed

Conversation

@zackees

@zackees zackees commented Nov 23, 2026

Copy link
Copy Markdown
Member

Why

The Tier 2 jobs download ~339 MB of .debs inside a 10-minute step. On a slow link that never finishes — run 45194364427 reached Get:145 of ~594 before the timeout. #5522 (merged) stopped throwing that away: the save step now runs on !cancelled() and keys entries by .deb count so restores pick up the newest.

But #5522 has nothing to publish if no run ever finishes. If every build run times out at 145 packages, every save is a 145-package archive, and the count-key scheme keeps re-saving the same size. The cache only advances when a build gets lucky.

What this adds

A scheduled job with no build to lose.

ci/seed_apt_cache.py:

  • restores the same cache entry the builds restore,
  • runs apt-get update + apt-get install --download-only into $TIER2_APT_ARCHIVES in bounded attempts (180 s update, 600 s install) under a 45-minute budget,
  • prints per-attempt progress and stops when the archive stops growing,
  • exits 0 whenever ≥1 package arrived — a partial seed is progress, and the save step runs either way.

apt-seed.yaml runs it on a 6-hour cron (41 */6 * * *) and on workflow_dispatch, then saves under the same content key with the .deb count appended.

Every run either completes the set or leaves a strictly larger archive than it found, so the cache converges with no human in the loop and no dependency on a build surviving its own timeout.

Parity is the whole point

A seed job that writes a different path or key warms nothing. ci/test_apt_seed.py pins both against build-project.yaml itself rather than against a copy of the key:

  • the seed's save key must equal the build's published key minus the hash suffix, plus the count,
  • the seed's restore prefix must match what the builds publish,
  • both must use path: ../../_temp/apt-archives/*.deb — actions/cache versions by the literal path, so a near-miss silently de-warms.

Edit either side and the test fails instead of the cache quietly stopping working.

Repository rules honoured

  • Root jobs in a scheduled workflow skip a scheduled run in a fork (bug: ci: scheduled workflows run on forks and fail every day #1258).
  • Cache writers publish only from master; setup-uv keeps the same save-cache expression.
  • The workflow is declared in ci.toml's [allow] workflows list.
  • Sanctioned ./.github/actions/cache only (CACHE-001), all actions SHA-pinned.

Validation

$ cd ci && uv run --no-project python -m unittest test_apt_seed test_ci_toml test_workflow_schedule_guard
Ran 60 tests ... OK

$ uv run --no-project ci/local_gate.py --only self-test
== self-test: ok        # full ci/ suite

Not covered by tests (needs a real runner): the actual apt-get download loop. First scheduled run is its proof; SEED_BUDGET_SECONDS / SEED_ATTEMPTS are env-tunable if 45 minutes turns out wrong.

The Tier 2 jobs download ~339 MB of .debs inside a ten-minute step. On a
slow link no build ever finishes the download, so #5522 (keep a timed-out
download instead of discarding it) preserves partial progress but has no run
that ends with a complete archive to publish. The archive only grows when a
build gets lucky.

Add ci/seed_apt_cache.py and apt-seed.yaml: a scheduled job with no build to
lose. It restores the same cache entry the builds restore, downloads the
package list into the same archive directory in bounded attempts, and saves
the larger result under the same content key with the .deb count appended.
Every scheduled run either finishes the set or leaves a strictly larger
archive than it found, so the cache converges without a human and without
depending on a build surviving its timeout.

The seed reuses build-project's exact path and key shape on purpose: a seed
that writes a different path or key warms nothing. ci/test_apt_seed.py pins
that parity against build-project.yaml rather than against a copy of the key,
so a future edit to either side fails the test instead of silently
de-warming the cache.

Job guards follow the repository rules: root jobs in a scheduled workflow
skip a scheduled run in a fork (#1258), cache writers publish only from
master, and the workflow is declared in ci.toml's allow list.
@zackees
zackees added this pull request to the merge queue Nov 23, 2026
Merged via the queue into master with commit 71b4764 Nov 23, 2026
43 checks passed
@zackees
zackees deleted the feat/apt-cache-self-seed branch November 23, 2026 20:37
zackees added a commit that referenced this pull request Nov 23, 2026
apt-packages.txt names packages, not versions, so the image identity hashes
a list that resolves to different content as -updates and -security move. A
stale archive also 404s a superseded .deb, which is the failure the cache
retry paths exist to paper over (#5497).

ci/apt_updates.py resolves the list against the current archive with
`apt-get -s --reinstall install` and renders a sorted name=version lock; the
scheduled job regenerates it and opens a pull request only when the lock
moves. A version bump that breaks Tier 2 is then reviewable in a diff instead
of being discovered inside a red merge queue.

The lock is generated, sorted and one package per line, so the PR diff is the
review. check exit status is non-zero on drift, so the same command works as
a local gate.

Stacked on #5527 because both edit ci.toml's workflow allow list.
KelboLive pushed a commit to KelboLive/obs-studio that referenced this pull request Nov 29, 2026
…ust#5528)

apt-packages.txt names packages, not versions, so the image identity hashes
a list that resolves to different content as -updates and -security move. A
stale archive also 404s a superseded .deb, which is the failure the cache
retry paths exist to paper over (obs-rust#5497).

ci/apt_updates.py resolves the list against the current archive with
`apt-get -s --reinstall install` and renders a sorted name=version lock; the
scheduled job regenerates it and opens a pull request only when the lock
moves. A version bump that breaks Tier 2 is then reviewable in a diff instead
of being discovered inside a red merge queue.

The lock is generated, sorted and one package per line, so the PR diff is the
review. check exit status is non-zero on drift, so the same command works as
a local gate.

Stacked on obs-rust#5527 because both edit ci.toml's workflow allow list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant