Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildctl: set fallback url for gha cache #5754

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

crazy-max
Copy link
Member

@crazy-max crazy-max commented Feb 18, 2025

relates to docker/buildx#3001 (comment)

We should always set url attr (if possible) when gha cache is used otherwise it will fail on BuildKit < 0.20 that doesn't support url_v2.

Also updates gha cache tests to support cache service v2.

@crazy-max crazy-max force-pushed the update-gha-cache-test branch from ca875b0 to d270bc0 Compare February 18, 2025 09:01
@crazy-max crazy-max changed the title buildctl: always set url attr for gha cache buildctl: set fallback url for gha cache Feb 18, 2025
@crazy-max crazy-max modified the milestones: v0.21.0, v0.20.0 Feb 18, 2025
@crazy-max crazy-max force-pushed the update-gha-cache-test branch from d270bc0 to a81bb08 Compare February 18, 2025 09:31
@crazy-max crazy-max requested a review from tonistiigi February 18, 2025 09:32
@crazy-max crazy-max marked this pull request as ready for review February 18, 2025 09:32
Comment on lines +519 to +520
* `url`: Cache server URL (default `$ACTIONS_CACHE_URL` or fallback to `$ACTIONS_RESULTS_URL`)
* `url_v2`: Cache v2 server URL if `$ACTIONS_CACHE_SERVICE_V2` set on the runner (default `$ACTIONS_RESULTS_URL`)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated docs as well for new attribute. Not sure if we should also add version?

@crazy-max crazy-max force-pushed the update-gha-cache-test branch from a81bb08 to f9917ce Compare February 18, 2025 14:00
return cache, errors.New("cache with type gha requires url parameter or $ACTIONS_RESULTS_URL")
// https://github.com/actions/toolkit/blob/2b08dc18f261b9fdd978b70279b85cbef81af8bc/packages/cache/src/internal/config.ts#L34-L35
if v, ok := os.LookupEnv("ACTIONS_RESULTS_URL"); ok {
cache.Attrs["url_v2"] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why skip the error if ACTIONS_CACHE_SERVICE_V2 is set but ACTIONS_RESULTS_URL is not?

Copy link
Member Author

@crazy-max crazy-max Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relates to #5754 (comment) so error would be handled from daemon side instead. Seems better to me for old daemon.

if !ok {
return cache, errors.New("cache with type gha requires token parameter or $ACTIONS_RUNTIME_TOKEN")
if v, ok := os.LookupEnv("ACTIONS_RUNTIME_TOKEN"); ok {
cache.Attrs["token"] = v
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that daemon will error anyway if you don't send the token. So why skip error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was to be aligned with buildx where we don't do this https://github.com/docker/buildx/blob/52f503e8068d4a09e7c1b17e4b88ae75b1f64651/util/buildflags/cache.go#L208-L231 but I can put that back if you prefer

@crazy-max crazy-max force-pushed the update-gha-cache-test branch from f9917ce to 4bbac8a Compare February 18, 2025 17:58
@crazy-max crazy-max requested a review from tonistiigi February 18, 2025 17:59
@crazy-max crazy-max force-pushed the update-gha-cache-test branch from 4bbac8a to 1c917b4 Compare February 18, 2025 18:07
@crazy-max crazy-max requested a review from tonistiigi February 18, 2025 18:08
@crazy-max crazy-max merged commit 4712052 into moby:master Feb 18, 2025
102 checks passed
@crazy-max crazy-max deleted the update-gha-cache-test branch February 18, 2025 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants