Skip to content

Commit 1d7f5f6

Browse files
authored
Changed error severity to warning for blobs downloading via redirect flow (#19519)
Changed error severity to warning for blobs downloading via redirect flow
1 parent 4fe4d0f commit 1d7f5f6

File tree

10 files changed

+76
-46
lines changed

10 files changed

+76
-46
lines changed

Tasks/DownloadBuildArtifactsV0/main.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ tl.setResourcePath(path.join(__dirname, 'task.json'));
2828
const area: string = 'DownloadBuildArtifacts';
2929
const DefaultParallelProcessingLimit: number = 8;
3030

31+
enum ErrorDisplayMode {
32+
ShowError = 0,
33+
ShowWarning,
34+
DoNotShowError,
35+
}
36+
3137
function getDefaultProps() {
3238
var hostType = (tl.getVariable('SYSTEM.HOSTTYPE') || "").toLowerCase();
3339
return {
@@ -326,7 +332,7 @@ async function main(): Promise<void> {
326332
await downloadPromise;
327333
} else {
328334
const operationName: string = `Download container - ${artifact.name}`;
329-
335+
330336
if (!preferRedirect || retryRedirectLimitDownload < 0) {
331337
// Keep current logic exactly as-is, for complete safety do not refactor yet
332338
const handlerConfig: IContainerHandlerConfig = { ...config, endpointUrl, templatePath, handler, preferRedirect: false };
@@ -335,12 +341,12 @@ async function main(): Promise<void> {
335341
operationName,
336342
() => downloadHandler.downloadResources(),
337343
retryLimitDownload,
338-
true
344+
ErrorDisplayMode.DoNotShowError
339345
).catch((reason) => {
340346
reject(reason);
341347
return;
342348
});
343-
349+
344350
downloadPromises.push(downloadPromise);
345351
await downloadPromise;
346352
} else {
@@ -352,7 +358,8 @@ async function main(): Promise<void> {
352358
const downloadPromise: Promise<models.ArtifactDownloadTicket[]> = executeWithRetries(
353359
operationName,
354360
() => downloadHandler.downloadResources(),
355-
retryRedirectLimitDownload
361+
retryRedirectLimitDownload,
362+
ErrorDisplayMode.ShowWarning
356363
).catch((reason) => {
357364
console.log(tl.loc("FollowingDownloadRedirectFailed", reason));
358365
const handlerConfig: IContainerHandlerConfig = { ...config, endpointUrl, templatePath, handler, preferRedirect: false };
@@ -407,28 +414,31 @@ async function main(): Promise<void> {
407414
return promise;
408415
}
409416

410-
function executeWithRetries(operationName: string, operation: () => Promise<any>, retryCount, silentFail: boolean = false): Promise<any> {
417+
function executeWithRetries(operationName: string, operation: () => Promise<any>, retryCount, errorDisplayMode: ErrorDisplayMode = ErrorDisplayMode.ShowError): Promise<any> {
411418
var executePromise = new Promise((resolve, reject) => {
412-
executeWithRetriesImplementation(operationName, operation, retryCount, resolve, reject, retryCount, silentFail);
419+
executeWithRetriesImplementation(operationName, operation, retryCount, resolve, reject, retryCount, errorDisplayMode);
413420
});
414421

415422
return executePromise;
416423
}
417424

418-
function executeWithRetriesImplementation(operationName: string, operation: () => Promise<any>, currentRetryCount, resolve, reject, retryCountLimit, silentFail) {
425+
function executeWithRetriesImplementation(operationName: string, operation: () => Promise<any>, currentRetryCount, resolve, reject, retryCountLimit, errorDisplayMode: ErrorDisplayMode) {
419426
operation().then((result) => {
420427
resolve(result);
421428
}).catch((error) => {
422429
if (currentRetryCount <= 0) {
423-
if (!silentFail) {
430+
if (errorDisplayMode == ErrorDisplayMode.ShowError) {
424431
tl.error(tl.loc("OperationFailed", operationName, error));
425432
}
433+
else if (errorDisplayMode == ErrorDisplayMode.ShowWarning) {
434+
tl.warning(tl.loc("OperationFailed", operationName, error));
435+
}
426436
reject(error);
427437
}
428438
else {
429439
console.log(tl.loc('RetryingOperation', operationName, currentRetryCount));
430440
currentRetryCount = currentRetryCount - 1;
431-
setTimeout(() => executeWithRetriesImplementation(operationName, operation, currentRetryCount, resolve, reject, retryCountLimit, silentFail), getRetryIntervalInSeconds(retryCountLimit - currentRetryCount) * 1000);
441+
setTimeout(() => executeWithRetriesImplementation(operationName, operation, currentRetryCount, resolve, reject, retryCountLimit, errorDisplayMode), getRetryIntervalInSeconds(retryCountLimit - currentRetryCount) * 1000);
432442
}
433443
});
434444
}
@@ -454,7 +464,7 @@ function configureDownloaderOptions(maxRetries?: number): engine.ArtifactEngineO
454464
if (maxRetries !== undefined) {
455465
downloaderOptions.retryLimit = maxRetries;
456466
}
457-
467+
458468
return downloaderOptions;
459469
}
460470

Tasks/DownloadBuildArtifactsV0/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 232,
12+
"Minor": 235,
1313
"Patch": 0
1414
},
1515
"groups": [

Tasks/DownloadBuildArtifactsV0/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 232,
12+
"Minor": 235,
1313
"Patch": 0
1414
},
1515
"groups": [
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|0.232.0
2-
Node20_229_3|0.232.1
1+
Default|0.235.0
2+
Node20_229_3|0.235.1

_generated/DownloadBuildArtifactsV0/main.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ tl.setResourcePath(path.join(__dirname, 'task.json'));
2828
const area: string = 'DownloadBuildArtifacts';
2929
const DefaultParallelProcessingLimit: number = 8;
3030

31+
enum ErrorDisplayMode {
32+
ShowError = 0,
33+
ShowWarning,
34+
DoNotShowError,
35+
}
36+
3137
function getDefaultProps() {
3238
var hostType = (tl.getVariable('SYSTEM.HOSTTYPE') || "").toLowerCase();
3339
return {
@@ -326,7 +332,7 @@ async function main(): Promise<void> {
326332
await downloadPromise;
327333
} else {
328334
const operationName: string = `Download container - ${artifact.name}`;
329-
335+
330336
if (!preferRedirect || retryRedirectLimitDownload < 0) {
331337
// Keep current logic exactly as-is, for complete safety do not refactor yet
332338
const handlerConfig: IContainerHandlerConfig = { ...config, endpointUrl, templatePath, handler, preferRedirect: false };
@@ -335,12 +341,12 @@ async function main(): Promise<void> {
335341
operationName,
336342
() => downloadHandler.downloadResources(),
337343
retryLimitDownload,
338-
true
344+
ErrorDisplayMode.DoNotShowError
339345
).catch((reason) => {
340346
reject(reason);
341347
return;
342348
});
343-
349+
344350
downloadPromises.push(downloadPromise);
345351
await downloadPromise;
346352
} else {
@@ -352,7 +358,8 @@ async function main(): Promise<void> {
352358
const downloadPromise: Promise<models.ArtifactDownloadTicket[]> = executeWithRetries(
353359
operationName,
354360
() => downloadHandler.downloadResources(),
355-
retryRedirectLimitDownload
361+
retryRedirectLimitDownload,
362+
ErrorDisplayMode.ShowWarning
356363
).catch((reason) => {
357364
console.log(tl.loc("FollowingDownloadRedirectFailed", reason));
358365
const handlerConfig: IContainerHandlerConfig = { ...config, endpointUrl, templatePath, handler, preferRedirect: false };
@@ -407,28 +414,31 @@ async function main(): Promise<void> {
407414
return promise;
408415
}
409416

410-
function executeWithRetries(operationName: string, operation: () => Promise<any>, retryCount, silentFail: boolean = false): Promise<any> {
417+
function executeWithRetries(operationName: string, operation: () => Promise<any>, retryCount, errorDisplayMode: ErrorDisplayMode = ErrorDisplayMode.ShowError): Promise<any> {
411418
var executePromise = new Promise((resolve, reject) => {
412-
executeWithRetriesImplementation(operationName, operation, retryCount, resolve, reject, retryCount, silentFail);
419+
executeWithRetriesImplementation(operationName, operation, retryCount, resolve, reject, retryCount, errorDisplayMode);
413420
});
414421

415422
return executePromise;
416423
}
417424

418-
function executeWithRetriesImplementation(operationName: string, operation: () => Promise<any>, currentRetryCount, resolve, reject, retryCountLimit, silentFail) {
425+
function executeWithRetriesImplementation(operationName: string, operation: () => Promise<any>, currentRetryCount, resolve, reject, retryCountLimit, errorDisplayMode: ErrorDisplayMode) {
419426
operation().then((result) => {
420427
resolve(result);
421428
}).catch((error) => {
422429
if (currentRetryCount <= 0) {
423-
if (!silentFail) {
430+
if (errorDisplayMode == ErrorDisplayMode.ShowError) {
424431
tl.error(tl.loc("OperationFailed", operationName, error));
425432
}
433+
else if (errorDisplayMode == ErrorDisplayMode.ShowWarning) {
434+
tl.warning(tl.loc("OperationFailed", operationName, error));
435+
}
426436
reject(error);
427437
}
428438
else {
429439
console.log(tl.loc('RetryingOperation', operationName, currentRetryCount));
430440
currentRetryCount = currentRetryCount - 1;
431-
setTimeout(() => executeWithRetriesImplementation(operationName, operation, currentRetryCount, resolve, reject, retryCountLimit, silentFail), getRetryIntervalInSeconds(retryCountLimit - currentRetryCount) * 1000);
441+
setTimeout(() => executeWithRetriesImplementation(operationName, operation, currentRetryCount, resolve, reject, retryCountLimit, errorDisplayMode), getRetryIntervalInSeconds(retryCountLimit - currentRetryCount) * 1000);
432442
}
433443
});
434444
}
@@ -454,7 +464,7 @@ function configureDownloaderOptions(maxRetries?: number): engine.ArtifactEngineO
454464
if (maxRetries !== undefined) {
455465
downloaderOptions.retryLimit = maxRetries;
456466
}
457-
467+
458468
return downloaderOptions;
459469
}
460470

_generated/DownloadBuildArtifactsV0/task.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 232,
12+
"Minor": 235,
1313
"Patch": 0
1414
},
1515
"groups": [
@@ -321,7 +321,7 @@
321321
}
322322
],
323323
"_buildConfigMapping": {
324-
"Default": "0.232.0",
325-
"Node20_229_3": "0.232.1"
324+
"Default": "0.235.0",
325+
"Node20_229_3": "0.235.1"
326326
}
327327
}

_generated/DownloadBuildArtifactsV0/task.loc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 232,
12+
"Minor": 235,
1313
"Patch": 0
1414
},
1515
"groups": [
@@ -321,7 +321,7 @@
321321
}
322322
],
323323
"_buildConfigMapping": {
324-
"Default": "0.232.0",
325-
"Node20_229_3": "0.232.1"
324+
"Default": "0.235.0",
325+
"Node20_229_3": "0.235.1"
326326
}
327327
}

_generated/DownloadBuildArtifactsV0_Node20/main.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ tl.setResourcePath(path.join(__dirname, 'task.json'));
2828
const area: string = 'DownloadBuildArtifacts';
2929
const DefaultParallelProcessingLimit: number = 8;
3030

31+
enum ErrorDisplayMode {
32+
ShowError = 0,
33+
ShowWarning,
34+
DoNotShowError,
35+
}
36+
3137
function getDefaultProps() {
3238
var hostType = (tl.getVariable('SYSTEM.HOSTTYPE') || "").toLowerCase();
3339
return {
@@ -326,7 +332,7 @@ async function main(): Promise<void> {
326332
await downloadPromise;
327333
} else {
328334
const operationName: string = `Download container - ${artifact.name}`;
329-
335+
330336
if (!preferRedirect || retryRedirectLimitDownload < 0) {
331337
// Keep current logic exactly as-is, for complete safety do not refactor yet
332338
const handlerConfig: IContainerHandlerConfig = { ...config, endpointUrl, templatePath, handler, preferRedirect: false };
@@ -335,12 +341,12 @@ async function main(): Promise<void> {
335341
operationName,
336342
() => downloadHandler.downloadResources(),
337343
retryLimitDownload,
338-
true
344+
ErrorDisplayMode.DoNotShowError
339345
).catch((reason) => {
340346
reject(reason);
341347
return;
342348
});
343-
349+
344350
downloadPromises.push(downloadPromise);
345351
await downloadPromise;
346352
} else {
@@ -352,7 +358,8 @@ async function main(): Promise<void> {
352358
const downloadPromise: Promise<models.ArtifactDownloadTicket[]> = executeWithRetries(
353359
operationName,
354360
() => downloadHandler.downloadResources(),
355-
retryRedirectLimitDownload
361+
retryRedirectLimitDownload,
362+
ErrorDisplayMode.ShowWarning
356363
).catch((reason) => {
357364
console.log(tl.loc("FollowingDownloadRedirectFailed", reason));
358365
const handlerConfig: IContainerHandlerConfig = { ...config, endpointUrl, templatePath, handler, preferRedirect: false };
@@ -407,28 +414,31 @@ async function main(): Promise<void> {
407414
return promise;
408415
}
409416

410-
function executeWithRetries(operationName: string, operation: () => Promise<any>, retryCount, silentFail: boolean = false): Promise<any> {
417+
function executeWithRetries(operationName: string, operation: () => Promise<any>, retryCount, errorDisplayMode: ErrorDisplayMode = ErrorDisplayMode.ShowError): Promise<any> {
411418
var executePromise = new Promise((resolve, reject) => {
412-
executeWithRetriesImplementation(operationName, operation, retryCount, resolve, reject, retryCount, silentFail);
419+
executeWithRetriesImplementation(operationName, operation, retryCount, resolve, reject, retryCount, errorDisplayMode);
413420
});
414421

415422
return executePromise;
416423
}
417424

418-
function executeWithRetriesImplementation(operationName: string, operation: () => Promise<any>, currentRetryCount, resolve, reject, retryCountLimit, silentFail) {
425+
function executeWithRetriesImplementation(operationName: string, operation: () => Promise<any>, currentRetryCount, resolve, reject, retryCountLimit, errorDisplayMode: ErrorDisplayMode) {
419426
operation().then((result) => {
420427
resolve(result);
421428
}).catch((error) => {
422429
if (currentRetryCount <= 0) {
423-
if (!silentFail) {
430+
if (errorDisplayMode == ErrorDisplayMode.ShowError) {
424431
tl.error(tl.loc("OperationFailed", operationName, error));
425432
}
433+
else if (errorDisplayMode == ErrorDisplayMode.ShowWarning) {
434+
tl.warning(tl.loc("OperationFailed", operationName, error));
435+
}
426436
reject(error);
427437
}
428438
else {
429439
console.log(tl.loc('RetryingOperation', operationName, currentRetryCount));
430440
currentRetryCount = currentRetryCount - 1;
431-
setTimeout(() => executeWithRetriesImplementation(operationName, operation, currentRetryCount, resolve, reject, retryCountLimit, silentFail), getRetryIntervalInSeconds(retryCountLimit - currentRetryCount) * 1000);
441+
setTimeout(() => executeWithRetriesImplementation(operationName, operation, currentRetryCount, resolve, reject, retryCountLimit, errorDisplayMode), getRetryIntervalInSeconds(retryCountLimit - currentRetryCount) * 1000);
432442
}
433443
});
434444
}
@@ -454,7 +464,7 @@ function configureDownloaderOptions(maxRetries?: number): engine.ArtifactEngineO
454464
if (maxRetries !== undefined) {
455465
downloaderOptions.retryLimit = maxRetries;
456466
}
457-
467+
458468
return downloaderOptions;
459469
}
460470

_generated/DownloadBuildArtifactsV0_Node20/task.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 232,
12+
"Minor": 235,
1313
"Patch": 1
1414
},
1515
"groups": [
@@ -325,7 +325,7 @@
325325
}
326326
],
327327
"_buildConfigMapping": {
328-
"Default": "0.232.0",
329-
"Node20_229_3": "0.232.1"
328+
"Default": "0.235.0",
329+
"Node20_229_3": "0.235.1"
330330
}
331331
}

_generated/DownloadBuildArtifactsV0_Node20/task.loc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 232,
12+
"Minor": 235,
1313
"Patch": 1
1414
},
1515
"groups": [
@@ -325,7 +325,7 @@
325325
}
326326
],
327327
"_buildConfigMapping": {
328-
"Default": "0.232.0",
329-
"Node20_229_3": "0.232.1"
328+
"Default": "0.235.0",
329+
"Node20_229_3": "0.235.1"
330330
}
331331
}

0 commit comments

Comments
 (0)