Skip to content

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

Open
MrLawrenceKwan wants to merge 1 commit intopermitio:masterfrom
MrLawrenceKwan:fix/cleanup-symlinks-on-clone-failure
Open

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

Conversation

@MrLawrenceKwan
Copy link

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

netlify bot commented Feb 15, 2026

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
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!

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

1 participant