1
0
Fork 0

changes to multipart download for s3

pull/1935/head
Prajjwal 2024-06-04 11:04:28 +05:30
parent d78ac4e851
commit 86e2ed1cf5
3 changed files with 29 additions and 41 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "github-actions.warp-cache", "name": "github-actions.warp-cache",
"version": "1.1.15", "version": "1.1.16",
"preview": true, "preview": true,
"description": "Github action to use WarpBuild's in-house cache offering", "description": "Github action to use WarpBuild's in-house cache offering",
"keywords": [ "keywords": [

View File

@ -137,49 +137,29 @@ export async function restoreCache(
} }
try { try {
let readStream: NodeJS.ReadableStream | undefined await cacheHttpClient.downloadCache(
let downloadCommandPipe = getDownloadCommandPipeForWget( cacheEntry.provider,
cacheEntry?.s3?.pre_signed_url cacheEntry.s3?.pre_signed_url,
) archivePath
await extractStreamingTar(
readStream,
archivePath,
compressionMethod,
downloadCommandPipe
) )
} catch (error) { } catch (error) {
core.debug(`Failed to download cache: ${error}`) core.info('Cache Miss. Failed to download cache.')
core.info( return undefined
`Streaming download failed. Likely a cloud provider issue. Retrying with multipart download`
)
// Wait 1 second
await new Promise(resolve => setTimeout(resolve, 1000))
try {
await cacheHttpClient.downloadCache(
cacheEntry.provider,
cacheEntry.s3?.pre_signed_url,
archivePath
)
} catch (error) {
core.info('Cache Miss. Failed to download cache.')
return undefined
}
if (core.isDebug()) {
await listTar(archivePath, compressionMethod)
}
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath)
core.info(
`Cache Size: ~${Math.round(
archiveFileSize / (1024 * 1024)
)} MB (${archiveFileSize} B)`
)
await extractTar(archivePath, compressionMethod)
} }
if (core.isDebug()) {
await listTar(archivePath, compressionMethod)
}
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath)
core.info(
`Cache Size: ~${Math.round(
archiveFileSize / (1024 * 1024)
)} MB (${archiveFileSize} B)`
)
await extractTar(archivePath, compressionMethod)
core.info('Cache restored successfully') core.info('Cache restored successfully')
break break
} }

View File

@ -9,6 +9,7 @@ import * as crypto from 'crypto'
import * as utils from './cacheUtils' import * as utils from './cacheUtils'
import {CompressionMethod} from './constants' import {CompressionMethod} from './constants'
import os from 'os'
import { import {
InternalCacheOptions, InternalCacheOptions,
ITypedResponseWithError, ITypedResponseWithError,
@ -211,7 +212,14 @@ export async function downloadCache(
): Promise<void> { ): Promise<void> {
switch (provider) { switch (provider) {
case 's3': case 's3':
await downloadCacheMultiConnection(archiveLocation, archivePath, 8) {
const numberOfConnections = 2 + os.cpus().length
await downloadCacheMultiConnection(
archiveLocation,
archivePath,
Math.min(numberOfConnections, 30)
)
}
break break
case 'gcs': { case 'gcs': {
if (!gcsToken) { if (!gcsToken) {