Fix temp directory leak in Azure fork deploy#110
Merged
Conversation
…URL is set Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix temporary directory leak in Azure fork deploy
Fix temp directory leak in Azure fork deploy
Mar 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a temp-directory disk leak in the Azure deploy flow when --repo-url is used, aligning behavior with the local deploy path by cleaning up the cloned repo directory after the command finishes.
Changes:
- Add deferred cleanup (
os.RemoveAll) for the repo root returned byfindRepoRoot()when--repo-urlis set.
Comment on lines
182
to
+188
| repoRoot, err := findRepoRoot() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if azureRepoURL != "" { | ||
| defer os.RemoveAll(repoRoot) | ||
| } |
There was a problem hiding this comment.
The new deferred cleanup only runs after findRepoRoot() succeeds. If --repo-url is set and gitclone.Clone() fails inside findRepoRoot(), the temp directory created by os.MkdirTemp is still leaked because the caller never receives repoRoot. To meet the “success or failure” cleanup requirement, ensure the temp dir is removed on clone error as well (e.g., remove it before returning the error, or return a cleanup func from findRepoRoot).
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.
findRepoRoot()creates a temp dir when--repo-urlis set but the callerrunDeployAzurenever cleaned it up, leaking ~100MB+ of cloned source per deploy. The local deploy path (deploy_local.go) already handles this correctly viadefer os.RemoveAll.Changes
cmd/deploy_azure.go: Addeddefer os.RemoveAll(repoRoot)inrunDeployAzureimmediately afterfindRepoRoot(), guarded byazureRepoURL != ""to avoid deleting a pre-existing on-disk repo root returned by the directory-walk branch.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.