Skip to content

Conversation

@robherley
Copy link
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
16 of 17 checks passed
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.

3 participants