Skip to content

Commit 89884a7

Browse files
Fix disk space issue in .NET PR creation by implementing sparse checkout (#9082)
The `Submit-AzureSdkForNetPr.ps1` script was performing a full clone of `azure-sdk-for-net` (several GB), causing the pipeline to run out of disk space and timeout. ## Changes - Replace full `git clone` with sparse checkout using cone mode - Fetch only the `eng/` directory (contains `Packages.Data.props` and `packages/http-client-csharp/`) - Use shallow fetch (`--depth 1`) to minimize history ```powershell # Before: Full clone (~several GB) git clone "https://github.com/$RepoOwner/$RepoName.git" $tempDir # After: Sparse checkout (~185MB) git init $tempDir git remote add origin "https://github.com/$RepoOwner/$RepoName.git" git sparse-checkout init --cone git sparse-checkout set eng/packages/http-client-csharp eng git fetch --depth 1 origin $BaseBranch git checkout $BaseBranch ``` <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Update .NET PR failing</issue_title> > <issue_description>For the last several runs, the update .NET PR script has timed out: > ##[error]System.IO.IOException: No space left on device : '/usr/local/vss-agent/4.264.2/_diag/Worker_20251123-215819-utc.log' > at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan`1 buffer, Int64 fileOffset) > at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) > at System.Diagnostics.TextWriterTraceListener.Flush() > at Microsoft.VisualStudio.Services.Agent.HostTraceListener.WriteHeader(String source, TraceEventType eventType, Int32 id) in /mnt/vss/_work/1/s/src/Microsoft.VisualStudio.Services.Agent/HostTraceListener.cs:line 131 > at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String message) > at Microsoft.VisualStudio.Services.Agent.Worker.Worker.RunAsync(String pipeIn, String pipeOut) in /mnt/vss/_work/1/s/src/Agent.Worker/Worker.cs:line 102 > at Microsoft.VisualStudio.Services.Agent.Worker.Program.MainAsync(IHostContext context, String[] args) in /mnt/vss/_work/1/s/src/Agent.Worker/Program.cs:line 54 > System.IO.IOException: No > ,##[error]The job running on agent azsdk-pool 1 ran longer than the maximum time of 60 minutes. For more information, see https://go.microsoft.com/fwlink/?linkid=2077134 > ,##[warning]Agent azsdk-pool 1 did not respond to a cancelation request with 00:05:00. > Pool: [azsdk-pool](https://dev.azure.com/azure-sdk/590cfd2a-581c-4dcb-a12e-6568ce786175/_settings/agentqueues?poolId=&queueId=532) > Agent: azsdk-pool 1 > Started: Yesterday at 1:58 PM > Duration: 1h 4m 59s > > Job preparation parameters > Parent pipeline used these runtime parameters > > https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/eng/pipeline/publish.yml#L126 > > When seeing the initial run it said the device was low on disk space. We may need to do a sparse checkout instead.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes #9081 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/typespec/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JoshLove-msft <[email protected]>
1 parent 96d38f6 commit 89884a7

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

packages/http-client-csharp/eng/scripts/Submit-AzureSdkForNetPr.ps1

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,48 @@ New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
7070
Write-Host "Created temp directory: $tempDir"
7171

7272
try {
73-
# Clone the repository
74-
Write-Host "Cloning azure-sdk-for-net repository..."
75-
git clone "https://github.com/$RepoOwner/$RepoName.git" $tempDir
73+
# Use sparse checkout to clone only the necessary files
74+
# This significantly reduces disk space usage as azure-sdk-for-net is a very large repository
75+
Write-Host "Setting up sparse checkout for azure-sdk-for-net repository..."
76+
77+
# Initialize empty git repository
78+
git init $tempDir
7679
if ($LASTEXITCODE -ne 0) {
77-
throw "Failed to clone repository"
80+
throw "Failed to initialize repository"
7881
}
79-
82+
8083
Push-Location $tempDir
84+
85+
# Add the remote
86+
git remote add origin "https://github.com/$RepoOwner/$RepoName.git"
87+
if ($LASTEXITCODE -ne 0) {
88+
throw "Failed to add remote"
89+
}
90+
91+
# Enable sparse checkout with cone mode for better performance
92+
git sparse-checkout init --cone
93+
if ($LASTEXITCODE -ne 0) {
94+
throw "Failed to initialize sparse checkout"
95+
}
96+
97+
# Set the sparse checkout patterns - only the directories we need
98+
git sparse-checkout set eng/packages/http-client-csharp eng
99+
if ($LASTEXITCODE -ne 0) {
100+
throw "Failed to set sparse checkout patterns"
101+
}
102+
103+
# Fetch only the main branch with depth 1
104+
Write-Host "Fetching $BaseBranch branch with sparse checkout..."
105+
git fetch --depth 1 origin $BaseBranch
106+
if ($LASTEXITCODE -ne 0) {
107+
throw "Failed to fetch repository"
108+
}
109+
110+
# Checkout the fetched branch
111+
git checkout $BaseBranch
112+
if ($LASTEXITCODE -ne 0) {
113+
throw "Failed to checkout $BaseBranch"
114+
}
81115

82116
# Create a new branch
83117
Write-Host "Creating branch $PRBranch..."

0 commit comments

Comments
 (0)