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

Multi-platform caching for buildx #981

Closed
wants to merge 1 commit into from

Conversation

blampe
Copy link
Contributor

@blampe blampe commented Feb 5, 2024

buildkit doesn't support multi-platform caches, so --cache-to with
--platforms can race such that only one platform is cached and subsequent
operations must re-build remaining platforms.

The recommended workaround is to perform a build without --cache-to, and then
perform P additional builds for each platform to push a platform-specific
cache.

We have two choices:

  1. We can detect this situation and refuse to build, with an error providing
    guidance for the user. An x86/ARM image would need 3 buildx.Image to
    propertly cache itself. If/when Docker resolves
    Pushing cache to "registry" cache with multi-node builder only uploads cache from one node docker/buildx#1044, users would need to clean up
    their extraneous resources in order to leverage upstream's behavior. In most
    cases this cleanup will simply never happen (assuming most users don't
    closely follow Docker implementation details.)
  2. We can detect this situation and automatically apply the workaround for the
    user. Only one buildx.Image is needed. If/when Docker resolves
    Pushing cache to "registry" cache with multi-node builder only uploads cache from one node docker/buildx#1044 we can instead rely on upstream
    behavior without any action needed from the user.

The workaround (option 1) is certainly possible with Pulumi today, however it's
awkward and I would rather not force this complexity on users who expect this
to Just Work™.

So this PR implements the second option. We detect this situation and munge the
build options such that we perform an initial build without --cache-to, and
then we push platform-specific caches. In the registry case we jump through
some hoops to prevent these derived cache keys from getting exposed as tag
names.

@blampe
Copy link
Contributor Author

blampe commented Feb 5, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @blampe and the rest of your teammates on Graphite Graphite

Copy link

github-actions bot commented Feb 5, 2024

Does the PR have any schema changes?

Does the PR have any schema changes?

Looking good! No breaking changes found.

New resources:

  • buildx/image.Image

Maintainer note: consult the runbook for dealing with any breaking changes.

@blampe blampe force-pushed the multi-platform-cache branch 2 times, most recently from 6ffd5df to 51fc69b Compare February 9, 2024 00:25
@blampe blampe force-pushed the unknown-inputs branch 2 times, most recently from 6c5dd77 to 7b29065 Compare February 10, 2024 00:45
@blampe blampe force-pushed the multi-platform-cache branch from 51fc69b to 55990b6 Compare February 10, 2024 00:45
@blampe blampe force-pushed the multi-platform-cache branch from 55990b6 to 98a76d1 Compare February 13, 2024 20:20
@blampe blampe force-pushed the multi-platform-cache branch from 98a76d1 to e777254 Compare February 13, 2024 22:28
@blampe blampe force-pushed the multi-platform-cache branch from e777254 to 6c70bf9 Compare February 13, 2024 23:48
@blampe blampe force-pushed the multi-platform-cache branch from 6c70bf9 to 993f4f2 Compare February 15, 2024 19:16
@blampe blampe mentioned this pull request Feb 15, 2024
@blampe blampe force-pushed the multi-platform-cache branch from 993f4f2 to 65c365b Compare February 15, 2024 19:29
@blampe blampe force-pushed the unknown-inputs branch 2 times, most recently from 98a9812 to 9a85afe Compare February 15, 2024 22:03
@blampe blampe force-pushed the multi-platform-cache branch from 65c365b to 7e84223 Compare February 15, 2024 22:06
@blampe blampe force-pushed the multi-platform-cache branch from 7e84223 to a3aebfb Compare February 29, 2024 19:29
@blampe blampe force-pushed the multi-platform-cache branch from a3aebfb to faee9fa Compare March 5, 2024 20:54
@blampe blampe closed this Apr 19, 2024
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.

1 participant