镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

cache: wrap create failures in ReserveCacheError - #1966

Merged
robherley merged 1 commit into
mainfrom
robherley/wrap-create-cache-err
Feb 25, 2025
Merged

robherley merged 1 commit into
mainfrom
robherley/wrap-create-cache-err

Conversation

@robherley

Copy link
Copy Markdown
Contributor

When we create cache entries, it's normal behavior for multiple jobs to "race" to create the same entry. In the cache v1 implementations, we suppressed these errors with just a normal log statement however in v2 we create an annotation with warning that is confusing folks.

Here's the v1 implementation:

const reserveCacheResponse = await cacheHttpClient.reserveCache(
key,
paths,
{
compressionMethod,
enableCrossOsArchive,
cacheSize: archiveFileSize
}
)
if (reserveCacheResponse?.result?.cacheId) {
cacheId = reserveCacheResponse?.result?.cacheId
} else if (reserveCacheResponse?.statusCode === 400) {
throw new Error(
reserveCacheResponse?.error?.message ??
`Cache size of ~${Math.round(
archiveFileSize / (1024 * 1024)
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
)
} else {
throw new ReserveCacheError(
`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${reserveCacheResponse?.error?.message}`
)
}

In v2, our client throws an error for a failed request, so we need to wrap that in the ReserveCacheError. That ensures we only emit an info statement, not a warning annotation:

} else if (typedError.name === ReserveCacheError.name) {
core.info(`Failed to save: ${typedError.message}`)

@robherley
robherley requested a review from a team as a code owner February 25, 2025 17:51
@robherley
robherley merged commit 1b9063e into main Feb 25, 2025
@robherley robherley mentioned this pull request Feb 26, 2025
7 of 10 tasks
Derrick-MUGISHA pushed a commit to Derrick-MUGISHA/toolkit that referenced this pull request Oct 12, 2026
…che-err

cache: wrap create failures in ReserveCacheError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants