Repository navigation
Fix repo sync: advance the bare clone, and name an out-of-space failure - #2
Merged
Merged
Conversation
`git clone --bare` creates no `remote.origin.fetch` refspec, so the sync's `git fetch --prune origin` had nothing to apply: it downloaded objects, wrote FETCH_HEAD, and left `refs/heads/<branch>` pointing wherever the original clone left it. Sync reported success on every cycle while the clone never moved, so every run worktreed the repository as it stood when it was first added. Fetch an explicit forced refspec for the repo's default branch, which is what actually advances the branch. No `--prune`: with an explicit refspec it would delete the clone's only branch as soon as that branch disappears upstream, leaving nothing to worktree from. The credential now travels as the fetch URL rather than being written to the clone's config first. That write was the only reason a routine sync touched `<clone>/config`, and it is the step that breaks first when the data volume fills — git rewrites the whole file through `config.lock`, so a failed write aborted the sync before git had even tried to fetch. The stored URL is still refreshed for `git lfs fetch`, but best-effort and only when it changed. Co-authored-by: Doug Rathbone <dougrathbone@users.noreply.github.com>
git's config writer reports a failed write through `write_error()`, which formats with `error()` rather than `error_errno()`. The errno is dropped, so an out-of-space config write arrives with no "No space left on device" for `isDiskFullError` to match, and the repository owner saw the raw dump instead: git remote failed (exit 128): error: failed to write new configuration file /data/repos/<id>/config.lock fatal: could not set 'remote.origin.url' to 'https://***@github.com/…' That message is only reachable after git created and opened the lock file, so it is neither a permission problem nor a stale lock (both fail earlier, with "could not lock config file") — the write itself failed, which in practice means the volume is full or over quota. Recognise it, and translate a disk-full clone/fetch failure into the actionable message the worktree path already used, so the repositories UI says what to do. Such failures report as a message rather than an exception: the raw text embeds the clone path, which splintered one operational problem into a separate issue per repository. Co-authored-by: Doug Rathbone <dougrathbone@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reported symptom was this on the repository picker in the agent editor:
Investigating it turned up two separate problems in
fetchRepo.1. That message means the data volume is full
git remote set-urlwrites the config throughconfig.lock. git reports afailed write via its
write_error()helper, which formats witherror()rather than
error_errno()— so the errno is dropped and nothing in the textsays "No space left on device" for
isDiskFullErrorto match on. Reproduced ona full tmpfs, which prints exactly the message above, byte for byte.
The message is only reachable after git created and opened the lock file, so
it is neither a permission problem nor a stale lock (both fail earlier with
"could not lock config file"). The write itself failed: the volume is full or
over quota.
So: recognise it, and translate a disk-full clone/fetch failure into the
actionable message the worktree path already used — "Not enough disk space to
sync this repository. Free space on the Conduit server or increase its data
volume, then retry." Those failures now report as a message rather than an
exception, because the raw git text embeds the clone path and was splintering
one operational problem into a separate Sentry issue per repository (the raw
text is kept as context).
2. Sync was never actually advancing the clone
git clone --barecreates noremote.origin.fetchrefspec — per git's owndocumentation it makes "neither remote-tracking branches nor the related
configuration variables". The sync's
git fetch --prune origintherefore hadno refspec to apply: it downloaded objects, wrote FETCH_HEAD, and left
refs/heads/<branch>pointing wherever the original clone left it.Every cycle reported success and updated "Synced 2 minutes ago" while the clone
never moved, so every run worktreed the repository as it stood when it was
first added.
The fix fetches an explicit forced refspec for the repo's default branch.
--pruneis dropped: with an explicit refspec it would delete the clone's onlybranch as soon as that branch disappears upstream, leaving nothing to worktree
from; without it that case fails loudly and the last good ref survives.
The credential also now travels as the fetch URL instead of being written to
the clone's config first. That write was the only reason a routine sync touched
<clone>/config— the very step that fails first on a full volume, abortingthe sync before git had even tried to fetch (an up-to-date repo needs no space
at all). It also contends with the per-run
configureWorktreeGitwrites, whichland in that same shared config file. The stored URL is still refreshed for
git lfs fetch, but best-effort and only when the credential changed.Worth noting a dead end here:
-c remote.origin.url=…does not work forthis.
urlis a multi-valued remote key, so a command-line value is appendedto the stored list rather than replacing it, and git still dials the stored URL
first. Verified — it fetched a deliberately bogus stored URL and failed.
Verification
refresh, the new disk-full detection, and the actionable
syncError.fetchRepo, andconfirmed the clone advanced and a fresh worktree contains the new content.
The old code left the clone at the original commit.
fetchRepoon a 100%-full tmpfs now yields"Not enough disk space to sync this repository…" instead of the config.lock
dump.
npm run buildpass.Follow-up, not fixed here
configureWorktreeGitrunsgit config user.nameandgit remote set-urlwiththe worktree as cwd, but a linked worktree shares the bare clone's config — so
those per-run writes land in
<clone>/config. Two concurrent runs of the samerepo therefore overwrite each other's committer identity, and one run's token
becomes the other's
originURL. Fixing it properly means per-worktree configor moving the identity/credential out of git config entirely, which is a larger
change than this one.