Skip to content

ci: keep a timed-out apt download instead of discarding it - #5522

Merged
zackees merged 1 commit into
masterfrom
fix/apt-partial-cache-save
Nov 23, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/apt-partial-cache-save

Conversation

@zackees

@zackees zackees commented Nov 23, 2026

Copy link
Copy Markdown
Member

The loop

On a slow link the 339 MB apt archive cannot download inside one 10-minute step window, and today a timed-out download is thrown away:

  1. Install Tier 2 Packages 📦 hits timeout-minutes: 10 with every finished .deb already in $TIER2_APT_ARCHIVES.
  2. Save apt Downloads 💾 never runs — its if: has no status function, so GitHub applies an implicit success().
  3. The next run restores nothing and starts again at Get:1.

Run 45194364427 reached Get:145 of roughly 594 packages and discarded all of it; step 10 Save apt Downloads 💾 shows skipped in the job's step list. That is the "keeps happening over and over" behaviour: the archive never advances past whatever one timeout window fetched, so it never converges.

Fix

1. Save on failure. Save apt Downloads 💾 now runs on (!cancelled()). The shared ./.github/actions/cache wrapper's inner save step gets the same treatment — an inner step would otherwise inherit the failed job status and still skip.

!cancelled() rather than always(): a cancelled run must not write a half-filled entry, but a failed one should keep its downloads.

2. Make the archive cumulative. A cache entry is immutable, so re-saving under the same key is a silent no-op and one always() save would freeze the archive at whatever the first failure fetched. The save key now ends in the .deb count at save time:

key: tier2-apt-ubuntu2604-f144425f-${{ hashFiles('.../apt-packages.txt') }}-${{ steps.apt-count.outputs.count }}

and both restore steps match the prefix and take the newest (largest) entry:

key: tier2-apt-ubuntu2604-f144425f-${{ hashFiles('.../apt-packages.txt') }}-complete
restore-keys: |
  tier2-apt-ubuntu2604-f144425f-${{ hashFiles('.../apt-packages.txt') }}-

The key stays content-derived — no run id, no PR number — so the original constraint that per-PR entries overflowed the 10 GB cache still holds, and saves remain master-only. Entries stop being created once the count stabilises, i.e. once the archive is complete.

Tests

ci/test_tier2_apt_cache.py and ci/test_tier2_build_setup.py updated to pin the new contract rather than the old one:

  • the save key must end in ${{ steps.apt-count.outputs.count }} and must not contain github.
  • both consumers must restore by prefix
  • the save step must survive a failure (!cancelled()) and must skip an empty archive
$ cd ci && uv run --no-project python -m unittest test_tier2_apt_cache test_tier2_build_setup
Ran 43 tests ... OK
$ uv run --no-project python -m unittest test_ci_toml test_qt_cache_identity test_tier2_cost_freshness \
    test_tier2_macos_cache test_tier2_modcache test_tier2_windows_cache test_tier2_image \
    test_ci_job_timeouts test_tier2_runtime_delta
Ran 119 tests ... OK

Not addressed here

This makes the download converge across runs on a slow link; it does not make it fast. The larger win is still ghcr.io/obs-rust/tier2-linux being readable anonymously so TIER2_PREBAKED can be true and the apt fetch leaves the critical path entirely — the package is currently private (anonymous probe 401), which needs package-admin access, tracked in #5501.

A slow mirror stops Install Tier 2 Packages at its 10-minute step timeout
with every finished .deb already in the archive dir, and Save apt Downloads
then never ran: its `if:` carried no status function, so GitHub applied an
implicit success() and skipped the step. Run 45194364427 reached Get:145 of
roughly 594 packages and threw all of it away; the next run started at Get:1
and timed out again. On a slow link the download cannot fit in one window,
so the loop never converges.

Two changes make progress cumulative:

  * Save apt Downloads runs on (!cancelled()) instead of success, so a
    timed-out install still persists what it downloaded. The shared cache
    action's inner save step gets the same treatment, since an inner step
    otherwise inherits the failed job status.
  * A cache entry is immutable, so saving again under the same key is a
    no-op. The save key now ends in the .deb count at save time and both
    restore steps match the prefix and take the newest entry. The key stays
    content-derived (no run or PR identifiers), so per-PR entries still
    cannot overflow the 10 GB cache.

Tests updated to pin the new contract: the save key must end in the count,
both consumers must restore by prefix, and the save must survive a failure.
@zackees
zackees enabled auto-merge November 23, 2026 18:09
@zackees
zackees added this pull request to the merge queue Nov 23, 2026
Merged via the queue into master with commit 5dd4470 Nov 23, 2026
44 checks passed
@zackees
zackees deleted the fix/apt-partial-cache-save branch November 23, 2026 18:24
KelboLive pushed a commit to KelboLive/obs-studio that referenced this pull request Nov 29, 2026
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 obs-rust#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 (obs-rust#1258), cache writers publish only from
master, and the workflow is declared in ci.toml's 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