fix: clean up partial clone artifacts when git clone fails (#634)#880
Open
MrLawrenceKwan wants to merge 1 commit intopermitio:masterfrom
Open
fix: clean up partial clone artifacts when git clone fails (#634)#880MrLawrenceKwan wants to merge 1 commit intopermitio:masterfrom
MrLawrenceKwan wants to merge 1 commit intopermitio:masterfrom
Conversation
When GitHub (or any git remote) is unavailable and clone_repository raises pygit2.GitError, the partially created repo directory was left behind with broken symlinks and incomplete files. On subsequent sync attempts, _discover_repository would find these artifacts, leading to an accumulation of broken symlinks in the filesystem. This fix removes the partial clone directory when a clone fails, preventing broken symlinks from accumulating. Fixes permitio#634
✅ Deploy Preview for opal-docs canceled.
|
Author
|
Hi maintainers 👋 Friendly follow-up — this fix is a small 7-line change and all CI checks have passed. Would love to get this reviewed when you have a moment. Let me know if any changes are needed. Thanks! |
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.
Problem
When GitHub (or any git remote) is unavailable and
clone_repositoryraisespygit2.GitError, the partially created repo directory is left behind with broken symlinks and incomplete files. On subsequent sync attempts, these artifacts accumulate in the filesystem, appearing as zombie-like processes in/proc.Root Cause
In
git_fetcher.py, the_clone()method catchespygit2.GitErrorbut does not clean up the partially-created repo directory atself._repo_path. The directory may contain broken symlinks and incomplete git objects from the interrupted clone.Fix
Added cleanup of the partial clone directory when
pygit2.GitErroris caught in_clone(). Usesshutil.rmtree(path, ignore_errors=True)to safely remove any residual files.Changes
packages/opal-server/opal_server/git_fetcher.pyThis is a minimal, surgical fix — no other files or logic are modified.
Fixes #634