From f120696e605d84c00e47e5c4b5184eadf3c7a360 Mon Sep 17 00:00:00 2001 From: Prajjwal Date: Fri, 17 May 2024 18:07:39 +0530 Subject: [PATCH] adds better info messages. reduces retry timeout for simple download. makes cache miss record instead of failing workflow --- packages/warp-cache/package.json | 2 +- packages/warp-cache/src/cache.ts | 25 +++++++++++++------ .../warp-cache/src/internal/downloadUtils.ts | 5 ++-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/warp-cache/package.json b/packages/warp-cache/package.json index 6f1ad0b9..241f2ce2 100644 --- a/packages/warp-cache/package.json +++ b/packages/warp-cache/package.json @@ -1,6 +1,6 @@ { "name": "github-actions.warp-cache", - "version": "1.1.7", + "version": "1.1.8", "preview": true, "description": "Github action to use WarpBuild's in-house cache offering", "keywords": [ diff --git a/packages/warp-cache/src/cache.ts b/packages/warp-cache/src/cache.ts index 65adce85..a5d89ad1 100644 --- a/packages/warp-cache/src/cache.ts +++ b/packages/warp-cache/src/cache.ts @@ -225,8 +225,9 @@ export async function restoreCache( downloadCommandPipe ) } catch (error) { + core.debug(`Failed to download cache: ${error}`) core.info( - `Streaming download failed. Retrying with multipart: ${error}` + `Streaming download failed. Likely a cloud provider issue. Retrying with multipart download` ) // Wait 1 second await new Promise(resolve => setTimeout(resolve, 1000)) @@ -239,16 +240,24 @@ export async function restoreCache( cacheEntry.gcs?.short_lived_token?.access_token ?? '' ) } catch (error) { + core.debug(`Failed to download cache: ${error}`) core.info( - `Multipart Download failed. Retrying with basic download: ${error}` + `Multipart download failed. Likely a cloud provider issue. Retrying with basic download` ) + // Wait 1 second await new Promise(resolve => setTimeout(resolve, 1000)) - await cacheHttpClient.downloadCacheSingleThread( - cacheEntry.provider, - archiveLocation, - archivePath, - cacheEntry.gcs?.short_lived_token?.access_token ?? '' - ) + // Try to download the cache using the basic method + try { + await cacheHttpClient.downloadCacheSingleThread( + cacheEntry.provider, + archiveLocation, + archivePath, + cacheEntry.gcs?.short_lived_token?.access_token ?? '' + ) + } catch (error) { + core.info('Cache Miss. Failed to download cache.') + return undefined + } } if (core.isDebug()) { diff --git a/packages/warp-cache/src/internal/downloadUtils.ts b/packages/warp-cache/src/internal/downloadUtils.ts index 611f87a1..a1e05325 100644 --- a/packages/warp-cache/src/internal/downloadUtils.ts +++ b/packages/warp-cache/src/internal/downloadUtils.ts @@ -317,7 +317,6 @@ export async function downloadCacheMultipartGCP( }) } catch (error) { core.debug(`Failed to download cache: ${error}`) - core.error(`Failed to download cache.`) throw error } } @@ -331,13 +330,14 @@ export async function downloadCacheGCP( const {bucketName, objectName} = utils.retrieveGCSBucketAndObjectName(archiveLocation) + storage.retryOptions.totalTimeout = 120 + await storage.bucket(bucketName).file(objectName).download({ destination: archivePath, validation: 'crc32c' }) } catch (error) { core.debug(`Failed to download cache: ${error}`) - core.error(`Failed to download cache.`) throw error } } @@ -367,7 +367,6 @@ export function downloadCacheStreamingGCP( return storage.bucket(bucketName).file(objectName).createReadStream() } catch (error) { core.debug(`Failed to download cache: ${error}`) - core.error(`Failed to download cache.`) throw error } }