fix(sidecar): adopt a non-empty non-git vault dir instead of failing to clone - #50
Merged
Merged
Conversation
…to clone On first boot the shared vault PVC is not empty: the Basic Memory app initialises the vault tree into the PVC root before the git-sync sidecar starts (they share one RWO volume, and Basic Memory owns the tree). The sidecar's attach() used clone_from, which refuses a non-empty target with "destination path '...' already exists and is not an empty directory", crash-looping the pod. Change attach() so that when the vault dir exists but is not a git repo, it `git init` (which adopts an existing directory), adds the canonical origin, fetches the branch and checks it out — mirroring a clone without requiring an empty target, and without discarding anything already on the volume. This is the correct behaviour for "Basic Memory owns the tree, the sidecar is its git backstop", and matches the AC that a reschedule (fresh mount) must not lose the notes. New unit test reproduces the production shape (a `secrets/` subdir already in the vault root, as the vault-agent overlay or Basic Memory's own init leaves) and asserts the sidecar attaches, keeps the existing dir, and has the origin. 13 tests pass (83% coverage), ruff + mypy clean.
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.
fix(sidecar): adopt a non-empty non-git vault dir instead of failing to clone
On first boot the shared vault PVC is not empty: the Basic Memory app
initialises the vault tree into the PVC root before the git-sync sidecar
starts (they share one RWO volume, and Basic Memory owns the tree). The
sidecar's attach() used clone_from, which refuses a non-empty target with
"destination path '...' already exists and is not an empty directory",
crash-looping the pod.
Change attach() so that when the vault dir exists but is not a git repo, it
git init(which adopts an existing directory), adds the canonical origin,fetches the branch and checks it out — mirroring a clone without requiring an
empty target, and without discarding anything already on the volume. This is
the correct behaviour for "Basic Memory owns the tree, the sidecar is its git
backstop", and matches the AC that a reschedule (fresh mount) must not lose
the notes.
New unit test reproduces the production shape (a
secrets/subdir already inthe vault root, as the vault-agent overlay or Basic Memory's own init leaves)
and asserts the sidecar attaches, keeps the existing dir, and has the origin.
13 tests pass (83% coverage), ruff + mypy clean.