Skip to content

fix(git): freshen mirror and report up-to-date on bundle fallback#396

Merged
worstell merged 1 commit into
mainfrom
worstell/git-bundle-fallback-freshen
Jul 22, 2026
Merged

fix(git): freshen mirror and report up-to-date on bundle fallback#396
worstell merged 1 commit into
mainfrom
worstell/git-bundle-fallback-freshen

Conversation

@worstell

Copy link
Copy Markdown
Contributor

Mirrors are per-pod but the cache is shared, so the pod serving a delta-bundle request can lag the pod that advertised the bundle URL. When that happens the base commit is missing from the local mirror (bundle creation fails with bad object) or local HEAD still equals the base (empty bundle). Both cases returned an error, forcing clients into a full freshen even when nothing changed upstream.

On a bundle cache miss the handler now fetches the mirror (rate-limited by the ref-check interval) and re-evaluates:

  • base == upstream HEAD → 204, surfaced to clients as client.ErrUpToDate, so no freshen is needed at all
  • base arrives with the fetch → normal generated bundle
  • base still unknown → 404 with a distinct miss_bad_base metric source

Bundle bases are also validated as full commit SHAs before hitting the repo.

Existing clients treat the 204/ErrUpToDate path the same as any other bundle failure (full freshen), so this is backward compatible; callers can opt into errors.Is(err, client.ErrUpToDate) to skip the fallback freshen entirely.

@worstell
worstell force-pushed the worstell/git-bundle-fallback-freshen branch 3 times, most recently from f8ec354 to 85c157f Compare July 22, 2026 22:03
@worstell
worstell marked this pull request as ready for review July 22, 2026 22:56
@worstell
worstell requested a review from a team as a code owner July 22, 2026 22:56
@worstell
worstell requested review from alecthomas and removed request for a team July 22, 2026 22:56
Mirrors are per-pod but the cache is shared, so the pod serving a bundle
request can lag the pod that advertised the bundle URL: the base commit
may be missing locally, or local HEAD may still equal base. Both cases
previously failed the request, forcing clients into a full freshen even
when nothing changed upstream.

On a bundle cache miss the handler now fetches the mirror (bounded by
the ref-check interval) and re-evaluates: a base at upstream HEAD
returns 204 so clients can skip freshening entirely (surfaced as
client.ErrUpToDate), and a base that arrives with the fetch is served
as a normal generated bundle. Bundle bases are also validated as full
commit SHAs, and the serve metric distinguishes up_to_date and
miss_bad_base outcomes.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019f8b6a-3778-7200-a3b4-c24b84edd973
@worstell
worstell force-pushed the worstell/git-bundle-fallback-freshen branch from 85c157f to 1a2959b Compare July 22, 2026 23:08
@worstell
worstell merged commit a87a1ce into main Jul 22, 2026
7 checks passed
@worstell
worstell deleted the worstell/git-bundle-fallback-freshen branch July 22, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants