Fix: Clean up repository cache on fetch failure to prevent resource leaks #850
+13
−4
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.
/claim #634
Fixes Issue
Closes #634
Changes proposed
This PR addresses a resource leak in
GitPolicyFetcherwhere repository objects were remaining in the internalreposcache even after a fetch operation failed (e.g., due to network issues or HTTP 500 errors from the git provider). This behavior could lead to "zombie" processes or lingering file descriptors/symbolic links as described in the issue.Specific changes:
packages/opal-server/opal_server/git_fetcher.py:fetchoperation withinfetch_and_notify_on_changesin atry...exceptblock.GitPolicyFetcher.reposdictionary if an exception occurs during fetching.Check List (Check all the applicable boxes)
Video
opal.fix.mp4
Note to reviewers
I verified this fix using a reproduction script that simulates a remote git failure (HTTP 500). Without the fix, the repository object remained in the cache. With the fix, the repository is correctly removed from the cache.