55
66import { type DockerBuildRequest as AcrDockerBuildRequest } from "@azure/arm-containerregistry" ;
77import { AzExtFsExtra , GenericParentTreeItem , activityFailContext , activityFailIcon } from "@microsoft/vscode-azext-utils" ;
8+ import * as retry from 'p-retry' ;
89import * as path from 'path' ;
910import { type Progress } from "vscode" ;
11+ import { ext } from "../../../../extensionVariables" ;
1012import { ExecuteActivityOutputStepBase , type ExecuteActivityOutput } from "../../../../utils/activity/ExecuteActivityOutputStepBase" ;
1113import { createActivityChildContext } from "../../../../utils/activity/activityUtils" ;
1214import { localize } from "../../../../utils/localize" ;
@@ -27,10 +29,20 @@ export class RunStep extends ExecuteActivityOutputStepBase<BuildImageInAzureImag
2729 dockerFilePath : path . basename ( context . dockerfilePath ) /* Assume the dockerfile is always in the root of the source */
2830 } ;
2931
30- const building : string = localize ( 'buildingImage' , 'Building image...' ) ;
31- progress . report ( { message : building } ) ;
32+ const retries = 3 ;
33+ await retry (
34+ async ( currentAttempt : number ) : Promise < void > => {
35+ const message : string = currentAttempt === 1 ?
36+ localize ( 'buildingImage' , 'Building image...' ) :
37+ localize ( 'buildingImageAttempt' , 'Building image (Attempt {0}/{1})...' , currentAttempt , retries + 1 ) ;
38+ progress . report ( { message : message } ) ;
39+ ext . outputChannel . appendLog ( message ) ;
3240
33- context . run = await context . client . registries . beginScheduleRunAndWait ( context . resourceGroupName , context . registryName , runRequest ) ;
41+ context . run = await context . client . registries . beginScheduleRunAndWait ( context . resourceGroupName , context . registryName , runRequest ) ;
42+
43+ } ,
44+ { retries, minTimeout : 2 * 1000 }
45+ ) ;
3446 } finally {
3547 if ( await AzExtFsExtra . pathExists ( context . tarFilePath ) ) {
3648 await AzExtFsExtra . deleteResource ( context . tarFilePath ) ;
0 commit comments