File tree Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Expand file tree Collapse file tree 4 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -23,27 +23,30 @@ const statAsync = promisify(stat);
2323*/
2424async function pullImageBySkopeoRepo (
2525 imageToPull : IPullableImage ,
26+ workloadName : string ,
2627) : Promise < IPullableImage > {
2728 // Scan image by digest if exists, other way fallback tag
2829 const scanId = imageToPull . imageWithDigest ?? imageToPull . imageName ;
2930 await skopeoCopy (
3031 scanId ,
3132 imageToPull . fileSystemPath ,
3233 imageToPull . skopeoRepoType ,
34+ workloadName ,
3335 ) ;
3436 return imageToPull ;
3537}
3638
3739export async function pullImages (
3840 images : IPullableImage [ ] ,
41+ workloadName : string ,
3942) : Promise < IPullableImage [ ] > {
4043 const pulledImages : IPullableImage [ ] = [ ] ;
4144 for ( const image of images ) {
4245 if ( ! image . fileSystemPath ) {
4346 continue ;
4447 }
4548 try {
46- const pulledImage = await pullImageBySkopeoRepo ( image ) ;
49+ const pulledImage = await pullImageBySkopeoRepo ( image , workloadName ) ;
4750 pulledImages . push ( pulledImage ) ;
4851 } catch ( error ) {
4952 logger . error (
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export async function pull(
3636 image : string ,
3737 destination : string ,
3838 skopeoRepoType : SkopeoRepositoryType ,
39+ workloadName : string ,
3940) : Promise < void > {
4041 const creds = await credentials . getSourceCredentials ( image ) ;
4142 const credentialsParameters = getCredentialParameters ( creds ) ;
@@ -56,12 +57,13 @@ export async function pull(
5657 sanitise : false ,
5758 } ) ;
5859
59- await pullWithRetry ( args , destination ) ;
60+ await pullWithRetry ( args , destination , workloadName ) ;
6061}
6162
6263async function pullWithRetry (
6364 args : Array < processWrapper . IProcessArgument > ,
6465 destination : string ,
66+ workloadName : string ,
6567) : Promise < void > {
6668 const MAX_ATTEMPTS = 10 ;
6769 const RETRY_INTERVAL_SEC = 0.2 ;
@@ -77,7 +79,7 @@ async function pullWithRetry(
7779 }
7880 } catch ( deleteErr ) {
7981 logger . warn (
80- { error : deleteErr , destination } ,
82+ { workloadName , error : deleteErr , destination } ,
8183 'could not clean up the Skopeo-copy archive' ,
8284 ) ;
8385 }
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export async function processWorkload(
4141 ) ;
4242 const imagesWithFileSystemPath = getImagesWithFileSystemPath ( uniqueImages ) ;
4343 const imagePullStartTimestampMs = Date . now ( ) ;
44- const pulledImages = await pullImages ( imagesWithFileSystemPath ) ;
44+ const pulledImages = await pullImages ( imagesWithFileSystemPath , workloadName ) ;
4545 const imagePullDurationMs = Date . now ( ) - imagePullStartTimestampMs ;
4646 if ( pulledImages . length === 0 ) {
4747 logger . info (
Original file line number Diff line number Diff line change @@ -58,7 +58,11 @@ describe('getImagesWithFileSystemPath()', () => {
5858describe ( 'pullImages()' , ( ) => {
5959 it ( 'skips on missing file system path' , async ( ) => {
6060 const badImage = [ { imageName : 'nginx:latest' } ] ;
61- const result = await scannerImages . pullImages ( badImage as IPullableImage [ ] ) ;
61+ const workloadName = 'workload' ;
62+ const result = await scannerImages . pullImages (
63+ badImage as IPullableImage [ ] ,
64+ workloadName ,
65+ ) ;
6266 expect ( result ) . toEqual ( [ ] ) ;
6367 } ) ;
6468} ) ;
You can’t perform that action at this time.
0 commit comments