Skip to content

Commit 53dc016

Browse files
authored
chunk level retry for file container upload. (#509)
1 parent 791c485 commit 53dc016

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

src/Agent.Listener/_project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"version": "1.0.0-*"
3535
},
3636
"Microsoft.Win32.Registry": "4.0.0",
37-
"vss-api-netcore": "0.5.24-private",
37+
"vss-api-netcore": "0.5.25-private",
3838
"System.ServiceProcess.ServiceController": "4.1.0",
3939
"System.IO.Compression.ZipFile": "4.0.1",
4040
"System.IO.FileSystem.AccessControl": "4.0.0",

src/Agent.Worker/Build/FileContainerServer.cs

+16-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Diagnostics;
1111
using Microsoft.VisualStudio.Services.WebApi;
1212
using System.Net.Http;
13+
using System.Net;
1314

1415
namespace Microsoft.VisualStudio.Services.Agent.Worker.Build
1516
{
@@ -183,8 +184,6 @@ private async Task<List<string>> UploadAsync(IAsyncCommandContext context, int u
183184
while (_fileUploadQueue.TryDequeue(out fileToUpload))
184185
{
185186
token.ThrowIfCancellationRequested();
186-
Interlocked.Increment(ref _filesProcessed);
187-
188187
using (FileStream fs = File.Open(fileToUpload, FileMode.Open, FileAccess.Read))
189188
{
190189
string itemPath = (_containerPath.TrimEnd('/') + "/" + fileToUpload.Remove(0, _sourceParentDirectory.Length + 1)).Replace('\\', '/');
@@ -198,6 +197,12 @@ private async Task<List<string>> UploadAsync(IAsyncCommandContext context, int u
198197
catch (OperationCanceledException) when (token.IsCancellationRequested)
199198
{
200199
context.Output(StringUtil.Loc("FileUploadCancelled", fileToUpload));
200+
if (response != null)
201+
{
202+
response.Dispose();
203+
response = null;
204+
}
205+
201206
throw;
202207
}
203208
catch (Exception ex)
@@ -208,7 +213,7 @@ private async Task<List<string>> UploadAsync(IAsyncCommandContext context, int u
208213
}
209214

210215
uploadTimer.Stop();
211-
if (catchExceptionDuringUpload || response.StatusCode != System.Net.HttpStatusCode.Created)
216+
if (catchExceptionDuringUpload || (response != null && response.StatusCode != HttpStatusCode.Created))
212217
{
213218
if (response != null)
214219
{
@@ -246,7 +251,15 @@ private async Task<List<string>> UploadAsync(IAsyncCommandContext context, int u
246251
}
247252
}
248253
}
254+
255+
if (response != null)
256+
{
257+
response.Dispose();
258+
response = null;
259+
}
249260
}
261+
262+
Interlocked.Increment(ref _filesProcessed);
250263
}
251264

252265
return failedFiles;

src/Agent.Worker/_project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"target": "project",
3434
"version": "1.0.0-*"
3535
},
36-
"vss-api-netcore": "0.5.24-private",
36+
"vss-api-netcore": "0.5.25-private",
3737
"System.Collections.NonGeneric": "4.0.1",
3838
"System.Diagnostics.TraceSource": "4.0.0",
3939
"System.Linq": "4.1.0",

src/Microsoft.VisualStudio.Services.Agent/Constants.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public enum OSPlatform
3838

3939
public static class Agent
4040
{
41-
public static readonly string Version = "2.104.2";
41+
public static readonly string Version = "2.105.0";
4242

4343
#if OS_LINUX
4444
public static readonly OSPlatform Platform = OSPlatform.Linux;

src/Microsoft.VisualStudio.Services.Agent/_project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"dependencies": {
2828
"NETStandard.Library": "1.6.0",
29-
"vss-api-netcore": "0.5.24-private",
29+
"vss-api-netcore": "0.5.25-private",
3030
"Microsoft.Win32.Registry": "4.0.0",
3131
"Newtonsoft.Json": "8.0.3",
3232
"System.Diagnostics.TraceSource": "4.0.0",

src/Test/_project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"System.Buffers": "4.0.0",
3131
"System.Reflection.TypeExtensions": "4.1.0",
3232
"System.Threading.ThreadPool": "4.0.10",
33-
"vss-api-netcore": "0.5.24-private",
33+
"vss-api-netcore": "0.5.25-private",
3434
"moq.netcore": "4.4.0-beta8",
3535
"xunit": "2.1.0",
3636
"xunit.console.netcore": "1.0.3-prerelease-00520-02",

0 commit comments

Comments
 (0)