Skip to content

fix: clean up partial clone artifacts when git clone fails (#634)#880

Closed
MrLawrenceKwan wants to merge 1 commit into
permitio:masterfrom
MrLawrenceKwan:fix/cleanup-symlinks-on-clone-failure
Closed

fix: clean up partial clone artifacts when git clone fails (#634)#880
MrLawrenceKwan wants to merge 1 commit into
permitio:masterfrom
MrLawrenceKwan:fix/cleanup-symlinks-on-clone-failure

Conversation

@MrLawrenceKwan

Copy link
Copy Markdown

Problem

When GitHub (or any git remote) is unavailable and clone_repository raises pygit2.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 catches pygit2.GitError but does not clean up the partially-created repo directory at self._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.GitError is caught in _clone(). Uses shutil.rmtree(path, ignore_errors=True) to safely remove any residual files.

Changes

  • 1 file changed, +7 lines
  • packages/opal-server/opal_server/git_fetcher.py

This is a minimal, surgical fix — no other files or logic are modified.

Fixes #634

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
@netlify

netlify Bot commented Feb 15, 2026

Copy link
Copy Markdown

Deploy Preview for opal-docs canceled.

Name Link
🔨 Latest commit 2eff2c4
🔍 Latest deploy log https://app.netlify.com/projects/opal-docs/deploys/699227cc3811f900088ab347

@MrLawrenceKwan

Copy link
Copy Markdown
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!

@zeevmoney

Copy link
Copy Markdown
Contributor

Thanks for this fix, @MrLawrenceKwan — the diagnosis is exactly right: _clone() catches pygit2.GitError without removing the partial clone at self._repo_path, leaving broken symlinks behind on repeated failures. We're consolidating issue #634, since there are several overlapping submissions for the same problem (#845, #864, #873, #875, #881), and the issue itself has been closed by the maintainers as a stale bounty. This change is minimal and correct, but it ships without test coverage and only handles the partial-clone-directory path, whereas other PRs also cover the pygit2 Repository / file-descriptor accumulation aspect. I'm closing this one in favor of the consolidated effort — please don't take it as a rejection of the analysis, which was spot on. Thank you for the contribution!

@zeevmoney zeevmoney closed this Jun 21, 2026
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.

OPAL Server doesn't clean up symbolic links when github is down

2 participants