Skip to content

feat: push manifest list - #2310

Closed
morlay wants to merge 9 commits into
dagger:mainfrom
morlay:poc-multi-arch
Closed

morlay wants to merge 9 commits into
dagger:mainfrom
morlay:poc-multi-arch

Conversation

@morlay

@morlay morlay commented Apr 26, 2022 •

Copy link
Copy Markdown
Contributor

Related: #1371

Continue #1467

Instead of extends `#Push`, adding new task `#PushManifestList` for creating the manifest list

Refs:

Not implatemented, just show api changes

@morlay
morlay force-pushed the poc-multi-arch branch 3 times, most recently from 6104809 to 2229a75 Compare April 26, 2022 16:07
@TomChv

TomChv commented Apr 26, 2022

Copy link
Copy Markdown
Member

I'm not sure it's possible to just push manifest list with Buildkit, at least, it wasn't possible when I worked on multi-platform.

You can take a look at #1467, it's a proof of concept that implement multi-platform in dagger Europa (old version but there shouldn't be much change in go code)

@morlay

morlay commented Apr 27, 2022

Copy link
Copy Markdown
Contributor Author

@TomChv

Yes. You're correct.

Have to use Control.Build to commit meta to Buildkit Worker for manifests create.

@morlay
morlay force-pushed the poc-multi-arch branch 6 times, most recently from 4cd4c38 to 5401287 Compare April 27, 2022 10:21
@morlay

morlay commented Apr 27, 2022 •

Copy link
Copy Markdown
Contributor Author

@TomChv

platform should be same as config, and need to pass from #Pull / #Dockerfile to #Push

otherwise, the arch-suffix images created by docker manifest create will got wrong manifest list (each manifest arch all equals Plan.platform, this is not correct)

so docker.#Image with store platform (may put it into core),
and it will be used for dispatching to arch-matched buildkit instance in multi-arch builder in future. (just like docker buildx did)

QEMU is too slow for compiling huge project. native buildkit is required for this case
When dagger support multi nodes builder, it will be possible to use single source configuration and build for anything.

@morlay
morlay force-pushed the poc-multi-arch branch 2 times, most recently from 3ad31e6 to 2a94724 Compare April 27, 2022 10:51
@morlay
morlay marked this pull request as ready for review April 27, 2022 10:58
@morlay
morlay requested review from a team, helderco and shykes as code owners April 27, 2022 10:58
@morlay
morlay force-pushed the poc-multi-arch branch 2 times, most recently from 363e3db to f1f4f54 Compare May 3, 2022 15:40

@TomChv TomChv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your amazing contribution 🚀

@aluzzardi @shykes That's a really interesting PR that follows what I did during autumn.

WDYT?

I left minors comments after a quick look, we must take time and put extra attention on this PR so you can wait before applying my comments.

Comment thread pkg/universe.dagger.io/docker/build.cue Outdated
Comment on lines 98 to 118

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Platform is also optional in core.#Dockerfile so you should not need that if statement

@morlay morlay May 3, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

have to use this. otherwise, cue will throw error.

Comment thread pkg/universe.dagger.io/docker/pull.cue Outdated
Comment on lines 31 to 33

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Platform is optional, you do not need that if statement?

Comment thread pkg/universe.dagger.io/docker/push.cue Resolved
Comment thread plan/task/dockerfile.go Resolved
@TomChv TomChv added area/engine About dagger core engine area/core kind/proposal labels May 3, 2022
@morlay
morlay force-pushed the poc-multi-arch branch 3 times, most recently from 6259476 to ddb3114 Compare May 3, 2022 16:03
@morlay

morlay commented May 16, 2022

Copy link
Copy Markdown
Contributor Author

never mind.
Just hope this feature could land asap. 😂

I want to continue do next big thing, multi-arch builder.

@sipsma

sipsma commented May 16, 2022

Copy link
Copy Markdown
Contributor

@morlay Appreciate the effort here and agree this is an important feature. I have a couple high-level thoughts + concerns.

In terms of your use case, you mentioned that "QEMU is too slow for compiling huge project" and it seems like your intention after this PR is to add support for distributing builds across multiple Buildkit daemons for each platform (correct me if wrong). I like that idea a lot, but it touches on a lot of issues related to support for multiple Buildkit workers that I think we need to design very carefully.

Even for just this PR, we may need to do a lot more iteration to nail down the cue interface, add a lot more tests to make sure it works seamlessly with the rest of the features (including the --platform cli flag), etc.

What I'm getting at is that it might be easier to approach this problem differently to unblock your use case faster. Here's one route I could imagine:

  1. Use the existing support for specifying --platform at the CLI to build and push images for different platforms. Concurrent executions of dagger do for each platform can be used, optionally with each one pointing to a different buildkit worker (via the BUILDKIT_HOST env var).
  2. To assemble the manifest list, just invoke a cli tool like docker manifest, regclient, crane, etc. from a Dagger action. This could be put in the universe action repo for re-usability too.
    • I saw that you tried to use docker manifest for this previously. Looking quickly at the CI output you linked to and associated code, I think the issue may just be that you were not providing access to the docker daemon's socket. There's an example of how to make this work in our ci.cue here. Please let me know if I'm misunderstanding this though as I don't have a ton of context other than the logs you posted.

This is just my personal feeling though. If there's some other reasons the above won't work or you'd rather figure out how to get this support merged into core, please let me know. I just want to make sure you are aware that we may need to take our time with these features.

Comment thread plan/task/push.go Resolved
@morlay

morlay commented May 17, 2022 •

Copy link
Copy Markdown
Contributor Author

@sipsma

In terms of your use case, you mentioned that "QEMU is too slow for compiling huge project" and it seems like your intention after this PR is to add support for distributing builds across multiple Buildkit daemons for each platform (correct me if wrong). I like that idea a lot, but it touches on a lot of issues related to support for multiple Buildkit workers that I think we need to design very carefully.

I agree. In fact, QEMU already enough for most usages.
Multi-arch builder only need for project like envoy (I'm maintaining the multi-arch istio, https://github.com/resf/istio, the envoy compiling have to use native host)

Different from docker buildx, dagger split steps in to small actions, so builder of dagger should support share outputs between multi-arch buildkits, instead merging all arch-matched steps in to matched buildkit,

Even for just this PR, we may need to do a lot more iteration to nail down the cue interface, add a lot more tests to make sure it works seamlessly with the rest of the features (including the --platform cli flag), etc.

It could be accept multi platforms, if when it set, it could push with the selected platform.

To assemble the manifest list, just invoke a cli tool like docker manifest, regclient, crane, etc. from a Dagger action. This could be put in the universe action repo for re-usability too.
I saw that you tried to use docker manifest for this previously. Looking quickly at the CI output you linked to and associated code, I think the issue may just be that you were not providing access to the docker daemon's socket. There's an example of how to make this work in our ci.cue here. Please let me know if I'm misunderstanding this though as I don't have a ton of context other than the logs you posted.

In github actions, it could.
Howerver, in my real-world CI, there is no docker.
Since I migrate to docker buildx with buildkits in k8s (mutli-arch cluster, gitlab-runner as tigger), I never need to use docker daemon.

This is why the PR needed, for non-docker environment

Why mv to dagger?
Just the composible actions will be make my team work better.
most developers don't want to care how the image build.
And we have to support amd64 & arm64 both, which increase the complexity of the Dockerfile.

@sipsma

sipsma commented May 24, 2022

Copy link
Copy Markdown
Contributor

@morlay

In github actions, it could. Howerver, in my real-world CI, there is no docker.

That's alright actually, I was just using docker manifest as an example but there are other command line tools that can construct and modify manifest lists without needing docker. Examples I'm aware of are:

Do you think any of those would work for you? If so, those tools could be wrapped in a reusable action and then put under a universe.dagger.io package.

@morlay

morlay commented May 24, 2022

Copy link
Copy Markdown
Contributor Author

@sipsma

Do you think any of those would work for you?

Nope. Multi-arch builds is the big feature of buildkit, I don't want to use another tool to combine manifest list.

In workflow like (webui + go service): (this should be common for projects)

%%{init:{'theme':'base'}}%%
flowchart TD

web_assets["web assets \n (only need to build on any one arch)"] 
go_build_amd64["go build for amd64"]
go_build_arm64["go build for arm64"]
multi_arch_image["build multi-arch image"]

web_assets 
--> go_build_amd64 & go_build_arm64
--> multi_arch_image
Loading

Without mult-arch support, we have to use

docker do push --platform=linux/amd64
docker do push --platform=linux/arm64
docker do manyfestlist

Another issue with those steps, web assets will be re-run for each arch.

With mult-arch support, we could simple run dagger do push to ship all images.
With platform declare in dagger files, it could clear actions' working platform.

So in another words,
--platform may use to filter working-platform-matched actions, instead of force defining all actions' working platform (like docker buildx did)

My recently projects, using dagger with mult-arch support (binaries: https://github.com/morlay/dagger/releases/tag/v0.3.0-beta):
https://github.com/octohelm/cuemod/blob/main/dagger.cue
https://github.com/octohelm/kubepkg/blob/main/dagger.cue
https://github.com/innoai-tech/media-toolkit/blob/main/dagger.cue
Will make pipeline simple:
https://github.com/innoai-tech/media-toolkit/blob/main/.github/workflows/ci.yml#L28-L33

@sipsma

sipsma commented May 25, 2022

Copy link
Copy Markdown
Contributor

@morlay

Nope. Multi-arch builds is the big feature of buildkit, I don't want to use another tool to combine manifest list.

I completely get this and absolutely agree we want to take advantage of buildkit's builtin features in the long-term. The only concern I have right now is that this PR makes a lot of decisions on how we want to approach this problem, which means we are committing to it (or forcing us to make backwards incompatible changes in the future). That's why I thought using a separate tool could be a faster option since it would work already today (even if it has some caveats like you said).

If we can find a way to get this same functionality but only by using experimental command line flags rather than modifying our core actions in cue, that might be another somewhat quicker path (but we'd need sign-off from other team members too of course). I could imagine something like this:

  1. We update the --platform experimental arg to accept multiple platforms. This results in builds being performed for each platform.
  2. If multiple platforms are specified there, the push action will push a manifest list instead of just a regular single image manifest

The only problem I'm not sure about is the one you mentioned where your web assets step is platform-agnostic and thus shouldn't be repeated for different platforms. Some of the LLB ops in buildkit are platform agnostic (local sources and mergeops come to mind), so if you can provide some more details on how that web assets step is implemented, I wonder if we can find a way to get that to work too.

@morlay

morlay commented May 26, 2022 •

Copy link
Copy Markdown
Contributor Author

@sipsma

If multiple platforms are specified there, the push action will push a manifest list instead of just a regular single image manifest

It not change old way, could use #Push & { image: "" } to push single image.
Only use #Push & { images: {} } will push manifest list with each platform but tag on the manifest list.

tag on manifest list is better than arch-suffix, it could let use change nothing of k8s manifests to deploy to k8s cluster with any arch node, even to k8s cluster with mulit-arch nodes like me.

The only problem I'm not sure about is the one you mentioned where your web assets step is platform-agnostic and thus shouldn't be repeated for different platforms. Some of the LLB ops in buildkit are platform agnostic (local sources and mergeops come to mind), so if you can provide some more details on how that web assets step is implemented, I wonder if we can find a way to get that to work too.

# For each step, it is run on docker container. so platform is the input too.
# go bulild will use the build.web's output for `go:embed` 
$ npm run build.web | go build

#  when dagger do build --platform=amd64             
$ npm run build.web --platform=amd64  | go build --platform=amd64
# `npm run build.web` will pull node for amd64, then run install & build.web

# when dagger do build --platform=arm64               
$ npm run build.web --platform=arm64  | go build --platform=arm64
# the platform changed, and the cache will not be hint.
# `npm run build.web` will pull node for arm64, then repeat run install & build.web

Like docker did, I prefer declare platform in dagger.cue, instead of use --platform to switch.

FROM --platform=${BUILD_PLATFORM} node:alpine

@github-actions

github-actions Bot commented Jun 9, 2022

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

TomChv and others added 9 commits June 10, 2022 09:37
Signed-off-by: Vasek - Tom C <[email protected]>
Signed-off-by: Morlay <[email protected]>
Signed-off-by: Vasek - Tom C <[email protected]>
Signed-off-by: Morlay <[email protected]>
With rebase, tests has been merged together into one single `@test`.
To correctly cache tests, they are now split into their own `@test`

This commit also update `pull_platform.cue` to use
templating instead of for loop according to the current dagger coding style.

Signed-off-by: Vasek - Tom C <[email protected]>
Signed-off-by: Morlay <[email protected]>
- Use templating instead of for loop in test.
- Reduce code duplication
- Clean up cue file
- Correctly exec test in `.bats`

Signed-off-by: Vasek - Tom C <[email protected]>
Signed-off-by: Morlay <[email protected]>
@morlay

morlay commented Jun 10, 2022

Copy link
Copy Markdown
Contributor Author

Hi @TomChv @shykes @aluzzardi @helderco @sipsma
Is there a conclusion?does dagger want to support this feature?

@sipsma

sipsma commented Jun 10, 2022

Copy link
Copy Markdown
Contributor

Hi @morlay, we discussed this PR the other day as a team and decided that while we all completely agree this feature is extremely important and we need to support it in the fullness of time, we currently don't have time to give its design+implementation the attention it requires, so it would be best to close it for now. To be clear, that's not to say there's anything wrong with your change, it's just that with any foundational feature like this we need to spend a lot of time validating it and considering as many future possibilities as we can to ensure it will be compatible with everything else we have planned.

The other thing we agreed on as a team is that we truly appreciate all the effort you've put into this and are very sorry that we have to reject the change for now. It's not something we do lightly since we love community contributions and adding new features like this that make Dagger better+easier to use. We just have to balance that against other practical considerations right now.

On our side, we are going to be more careful about being clear upfront on whether PRs are likely to be merged or not so we end up making the best use of everyone's time. Also though, we recommend first running proposed features+designs by Dagger maintainers and getting confirmation that it's the right time to pursue them before diving into the implementation. This is briefly mentioned in our online contributing docs, but I'll also update our CONTRIBUTING.md to make this more clear.

@sipsma sipsma closed this Jun 10, 2022
@morlay

morlay commented Jun 10, 2022

Copy link
Copy Markdown
Contributor Author

Hi @morlay, we discussed this PR the other day as a team and decided that while we all completely agree this feature is extremely important and we need to support it in the fullness of time, we currently don't have time to give its design+implementation the attention it requires, so it would be best to close it for now. To be clear, that's not to say there's anything wrong with your change, it's just that with any foundational feature like this we need to spend a lot of time validating it and considering as many future possibilities as we can to ensure it will be compatible with everything else we have planned.

The other thing we agreed on as a team is that we truly appreciate all the effort you've put into this and are very sorry that we have to reject the change for now. It's not something we do lightly since we love community contributions and adding new features like this that make Dagger better+easier to use. We just have to balance that against other practical considerations right now.

On our side, we are going to be more careful about being clear upfront on whether PRs are likely to be merged or not so we end up making the best use of everyone's time. Also though, we recommend first running proposed features+designs by Dagger maintainers and getting confirmation that it's the right time to pursue them before diving into the implementation. This is briefly mentioned in our online contributing docs, but I'll also update our CONTRIBUTING.md to make this more clear.

Fine. I think I have to use my forked dagger. https://github.com/morlay/dagger/releases/tag/latest

@helderco helderco mentioned this pull request Jun 17, 2022
@morlay
morlay deleted the poc-multi-arch branch November 3, 2022 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/engine About dagger core engine kind/proposal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants