From c202c38407d5fe9fce9e010fa5547f2ffecb53b4 Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Tue, 16 Aug 2022 04:14:27 +0000 Subject: [PATCH 1/6] Added custom user inputted timeout --- packages/cache/RELEASES.md | 5 ++++- packages/cache/__tests__/options.test.ts | 18 ++++++++++++++++++ packages/cache/package-lock.json | 4 ++-- packages/cache/package.json | 2 +- packages/cache/src/options.ts | 11 +++++++++++ 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/packages/cache/RELEASES.md b/packages/cache/RELEASES.md index 8fc7ba29..8ffe364c 100644 --- a/packages/cache/RELEASES.md +++ b/packages/cache/RELEASES.md @@ -80,4 +80,7 @@ - Added 1 hour timeout for the download stuck issue [#810](https://github.com/actions/cache/issues/810). ### 3.0.3 -- Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810). \ No newline at end of file +- Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810). + +### 3.0.4 +- Allowing users to provide a custom timeout as input for aborting cache download using an environment variable `CACHE_DOWNLOAD_TIMEOUT_MINS`. Default is 1 hour. \ No newline at end of file diff --git a/packages/cache/__tests__/options.test.ts b/packages/cache/__tests__/options.test.ts index 5ec7b146..e2cdf468 100644 --- a/packages/cache/__tests__/options.test.ts +++ b/packages/cache/__tests__/options.test.ts @@ -55,3 +55,21 @@ test('getUploadOptions overrides all settings', async () => { expect(actualOptions).toEqual(expectedOptions) }) + +test('getDownloadOptions overrides download timeout minutes', async () => { + const expectedOptions: DownloadOptions = { + useAzureSdk: false, + downloadConcurrency: 14, + timeoutInMs: 20000, + segmentTimeoutInMs: 3600000 + } + process.env.CACHE_DOWNLOAD_TIMEOUT_MINS = '10' + const actualOptions = getDownloadOptions(expectedOptions) + + expect(actualOptions.useAzureSdk).toEqual(expectedOptions.useAzureSdk) + expect(actualOptions.downloadConcurrency).toEqual( + expectedOptions.downloadConcurrency + ) + expect(actualOptions.timeoutInMs).toEqual(expectedOptions.timeoutInMs) + expect(actualOptions.segmentTimeoutInMs).toEqual(600000) +}) diff --git a/packages/cache/package-lock.json b/packages/cache/package-lock.json index 87d24d4d..0ea84f44 100644 --- a/packages/cache/package-lock.json +++ b/packages/cache/package-lock.json @@ -1,12 +1,12 @@ { "name": "@actions/cache", - "version": "3.0.3", + "version": "3.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@actions/cache", - "version": "3.0.3", + "version": "3.0.4", "license": "MIT", "dependencies": { "@actions/core": "^1.2.6", diff --git a/packages/cache/package.json b/packages/cache/package.json index 476e8562..6a3d476f 100644 --- a/packages/cache/package.json +++ b/packages/cache/package.json @@ -1,6 +1,6 @@ { "name": "@actions/cache", - "version": "3.0.3", + "version": "3.0.4", "preview": true, "description": "Actions cache lib", "keywords": [ diff --git a/packages/cache/src/options.ts b/packages/cache/src/options.ts index eefe9731..d3f716b8 100644 --- a/packages/cache/src/options.ts +++ b/packages/cache/src/options.ts @@ -112,10 +112,21 @@ export function getDownloadOptions(copy?: DownloadOptions): DownloadOptions { result.segmentTimeoutInMs = copy.segmentTimeoutInMs } } + const customDownloadTimeoutMins = process.env['CACHE_DOWNLOAD_TIMEOUT_MINS'] + if ( + customDownloadTimeoutMins && + !isNaN(Number(customDownloadTimeoutMins)) && + isFinite(Number(customDownloadTimeoutMins)) + ) { + result.segmentTimeoutInMs = Number(customDownloadTimeoutMins) * 60 * 1000 + } core.debug(`Use Azure SDK: ${result.useAzureSdk}`) core.debug(`Download concurrency: ${result.downloadConcurrency}`) core.debug(`Request timeout (ms): ${result.timeoutInMs}`) + core.debug( + `Cache download timeout mins env var: ${process.env['CACHE_DOWNLOAD_TIMEOUT_MINS']}` + ) core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`) return result From 4b6b45fe18c542cabfb32eb24f78a67377aa5255 Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Thu, 18 Aug 2022 05:32:49 +0000 Subject: [PATCH 2/6] Updated cache download to segment download --- packages/cache/README.md | 5 +++++ packages/cache/RELEASES.md | 2 +- packages/cache/__tests__/options.test.ts | 2 +- packages/cache/src/options.ts | 13 +++++++------ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/cache/README.md b/packages/cache/README.md index 541b1155..58f959ec 100644 --- a/packages/cache/README.md +++ b/packages/cache/README.md @@ -42,3 +42,8 @@ const restoreKeys = [ const cacheKey = await cache.restoreCache(paths, key, restoreKeys) ``` +##### Cache segment restore timeout + +Starting `v3.0.5` of `actions/toolkit`, in case any issue occurs while downloading the cache, the download will be aborted by default within 1 hour if any `segment` doesn't download completely. A `segment` is limited to size of `1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner. So for any cache that exceeds the size of one segment, multiple segments will be downloaded in sequence to complete the download. + +To customise the `segment` download timeout, an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS` needs to be set with the timeout minutes. This way the download wouldn't get stuck forever and proceed to next step in the workflow without any problem. diff --git a/packages/cache/RELEASES.md b/packages/cache/RELEASES.md index 8ffe364c..f654b0a0 100644 --- a/packages/cache/RELEASES.md +++ b/packages/cache/RELEASES.md @@ -83,4 +83,4 @@ - Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810). ### 3.0.4 -- Allowing users to provide a custom timeout as input for aborting cache download using an environment variable `CACHE_DOWNLOAD_TIMEOUT_MINS`. Default is 1 hour. \ No newline at end of file +- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `CACHE_DOWNLOAD_TIMEOUT_MINS`. Default is 1 hour. \ No newline at end of file diff --git a/packages/cache/__tests__/options.test.ts b/packages/cache/__tests__/options.test.ts index e2cdf468..83d9b227 100644 --- a/packages/cache/__tests__/options.test.ts +++ b/packages/cache/__tests__/options.test.ts @@ -63,7 +63,7 @@ test('getDownloadOptions overrides download timeout minutes', async () => { timeoutInMs: 20000, segmentTimeoutInMs: 3600000 } - process.env.CACHE_DOWNLOAD_TIMEOUT_MINS = '10' + process.env.SEGMENT_DOWNLOAD_TIMEOUT_MINS = '10' const actualOptions = getDownloadOptions(expectedOptions) expect(actualOptions.useAzureSdk).toEqual(expectedOptions.useAzureSdk) diff --git a/packages/cache/src/options.ts b/packages/cache/src/options.ts index d3f716b8..652899a2 100644 --- a/packages/cache/src/options.ts +++ b/packages/cache/src/options.ts @@ -112,20 +112,21 @@ export function getDownloadOptions(copy?: DownloadOptions): DownloadOptions { result.segmentTimeoutInMs = copy.segmentTimeoutInMs } } - const customDownloadTimeoutMins = process.env['CACHE_DOWNLOAD_TIMEOUT_MINS'] + const segmentDownloadTimeoutMins = + process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS'] if ( - customDownloadTimeoutMins && - !isNaN(Number(customDownloadTimeoutMins)) && - isFinite(Number(customDownloadTimeoutMins)) + segmentDownloadTimeoutMins && + !isNaN(Number(segmentDownloadTimeoutMins)) && + isFinite(Number(segmentDownloadTimeoutMins)) ) { - result.segmentTimeoutInMs = Number(customDownloadTimeoutMins) * 60 * 1000 + result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1000 } core.debug(`Use Azure SDK: ${result.useAzureSdk}`) core.debug(`Download concurrency: ${result.downloadConcurrency}`) core.debug(`Request timeout (ms): ${result.timeoutInMs}`) core.debug( - `Cache download timeout mins env var: ${process.env['CACHE_DOWNLOAD_TIMEOUT_MINS']}` + `Cache segment download timeout mins env var: ${process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']}` ) core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`) From 846a0af6ec6915ffac907f73af4c5cb7b49b9306 Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Thu, 18 Aug 2022 06:38:04 +0000 Subject: [PATCH 3/6] corrected environment variable --- packages/cache/RELEASES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cache/RELEASES.md b/packages/cache/RELEASES.md index f654b0a0..4f177f4c 100644 --- a/packages/cache/RELEASES.md +++ b/packages/cache/RELEASES.md @@ -82,5 +82,5 @@ ### 3.0.3 - Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810). -### 3.0.4 -- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `CACHE_DOWNLOAD_TIMEOUT_MINS`. Default is 1 hour. \ No newline at end of file +### 3.0.5 +- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MIN`. Default is 1 hour. \ No newline at end of file From 5c5e91f040ecf177de8eea4a62a9b9e5ce30ed69 Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Thu, 18 Aug 2022 06:46:57 +0000 Subject: [PATCH 4/6] Updated Segment readme and version --- packages/cache/README.md | 4 ++-- packages/cache/RELEASES.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cache/README.md b/packages/cache/README.md index 58f959ec..b8e50401 100644 --- a/packages/cache/README.md +++ b/packages/cache/README.md @@ -44,6 +44,6 @@ const cacheKey = await cache.restoreCache(paths, key, restoreKeys) ##### Cache segment restore timeout -Starting `v3.0.5` of `actions/toolkit`, in case any issue occurs while downloading the cache, the download will be aborted by default within 1 hour if any `segment` doesn't download completely. A `segment` is limited to size of `1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner. So for any cache that exceeds the size of one segment, multiple segments will be downloaded in sequence to complete the download. +Version `v3.0.4` of cache package introduces a segment download timeout. A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss. -To customise the `segment` download timeout, an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS` needs to be set with the timeout minutes. This way the download wouldn't get stuck forever and proceed to next step in the workflow without any problem. +Default value of this timeout is 1 hour and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. \ No newline at end of file diff --git a/packages/cache/RELEASES.md b/packages/cache/RELEASES.md index 4f177f4c..b9ff58f7 100644 --- a/packages/cache/RELEASES.md +++ b/packages/cache/RELEASES.md @@ -82,5 +82,5 @@ ### 3.0.3 - Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810). -### 3.0.5 +### 3.0.4 - Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MIN`. Default is 1 hour. \ No newline at end of file From 0be752bc46fe804c15b2ce9155e49ba7f47e2ae5 Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Thu, 18 Aug 2022 09:14:58 +0000 Subject: [PATCH 5/6] Updated readme --- packages/cache/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cache/README.md b/packages/cache/README.md index b8e50401..eaa30e7b 100644 --- a/packages/cache/README.md +++ b/packages/cache/README.md @@ -44,6 +44,6 @@ const cacheKey = await cache.restoreCache(paths, key, restoreKeys) ##### Cache segment restore timeout -Version `v3.0.4` of cache package introduces a segment download timeout. A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss. +A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. Version `v3.0.4` of cache package introduces a segment download timeout. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss. -Default value of this timeout is 1 hour and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. \ No newline at end of file +Default value of this timeout is 60 minutes and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with timeout value in minutes. \ No newline at end of file From 6c9b023c1b958ce9219084216b238e62ae810cd9 Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Thu, 18 Aug 2022 09:16:59 +0000 Subject: [PATCH 6/6] Updated releases.md --- packages/cache/RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cache/RELEASES.md b/packages/cache/RELEASES.md index b9ff58f7..dcc91a32 100644 --- a/packages/cache/RELEASES.md +++ b/packages/cache/RELEASES.md @@ -83,4 +83,4 @@ - Bug fixes for download stuck issue [#810](https://github.com/actions/cache/issues/810). ### 3.0.4 -- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MIN`. Default is 1 hour. \ No newline at end of file +- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MIN`. Default is 60 minutes. \ No newline at end of file