Repository navigation
simpler Host API - #3560
simpler Host API#3560
Conversation
There was a problem hiding this comment.
bikeshedding: if export is on Directory, why not have import (or syncFromHost) on Directory too? e.g.
type Directory {
...
# merge the contents of hostPath from the host into destPath in the directory
syncFromHost(hostPath: String!, destPath: String!, include: [String!], exclude: [String!]) Directory!
...
}Just seems more intuitive, but if you and no one else agree please ignore.
There was a problem hiding this comment.
One thing to keep in mind is that we also plan to have File.export and Container.export.
Though to your point, I could see us adding File.import (load a single file into a File) and Container.import (load an OCI tarball into a Container).
@shykes @aluzzardi 🚲 🏚️ 🖌️
There was a problem hiding this comment.
Thought about this a bit more, I think it's OK the way it is.
This was the dealbreaker: if we were to add a Container.import that reads from the host filesystem, people wouldn't be able to import from a DirectoryID (let's say you ran nix build or something to build an OCI tarball in Dagger). But if they can import from a DirectoryID, they can also import from the host filesystem.
So it seems to me that it's an anti-goal for each object to support importing from the host filesystem, because they should ideally be reading from a DirectoryID for maximum flexibility instead.
I know this wasn't your argument, I'm just countering my own "logical conclusion." :)
Here are some supporting arguments for the current scheme:
- Having
exporton each type feels more natural than havingexportX,exportY, andexportZon theHost. - Having directories be "created" from their origin is already a common pattern, e.g.
Container.directory - If we inverted it we might end up with
Directory.fromContainerwhich feels like the type of pattern we're avoiding in step 1.
I don't know if I'm making sense here, there might be a better way to express it.
|
I don't have any comments on the implementation... but I like the design (presuming we can sort out any potential security issues). |
0c55f3b to
7b6973e
Compare
There was a problem hiding this comment.
This is going to break the automatic spin up of buildkitd I think.
I'm personally okay with moving to being based on master branch builds of buildkit, but making that switch now is going to increase the scope here of this PR. Maybe it's doable relatively quickly, but if not I don't think we should block the PR on it. We can use the copied source for now and then switch to master buildkit in a follow up.
There was a problem hiding this comment.
Oh right - I just had to fix that code to handle replace rules, so I think I can just tweak it again to use master if the version isn't a regular semver.
edit: or maybe the exact commit sha? I'll check if they push those tags, too.
There was a problem hiding this comment.
The problem is that the code looks at the version of buildkit in our dependencies and then pulls the buildkit image based on that: https://github.com/sipsma/dagger/blob/ab7fba6ce6611a5eb0c279f8db42bb45b1cca11f/internal/buildkitd/buildkitd.go#L85-L85
So before it was v0.10.5 and we thus pulled moby/buildkit:v0.10.5.
There are images built from the master branch but I don't know of a way to map the commit SHA we depend on to those images. Honestly, I think I'd be okay with just hardcoding an image digest to pull for moby/buildkit and then adding a test to make sure we always keep it updated with our client. Not having to wait for official buildkit releases will resolve so many headaches (i.e. the dumb issue where running go get -u breaks the fsutil dep or this fix from May that was made for a bug encountered by a Dagger Europa user which still has not made it to us...)
I think we can then add a test that makes sure our client dependency is aligned with the server; when I currently run docker exec -it dagger-buildkitd buildctl --version I get a commit SHA, so I think we can use that in the test (since buildctl version inside that container should be the same as buildkitd).
THEN when we switch to having our own embedded buildkitd and image and all that I think this will likely all still be useful and what we want, so probably not throwaway work either.
There was a problem hiding this comment.
Again, this might be too much for this PR, another option is to go back to copying code for a bit, then make these changes in a follow up. I'm also happy to do that follow up too to help distribute the workload here.
There was a problem hiding this comment.
I think I came up with something that should cover all of the following cases:
- Pointing to an unreleased version for client-only changes.
- Pointing to an unreleased version for server changes.
- Pointing to a fork for either of the above.
The gist of it is we'll now grab the version from replace lines too, and we just maintain a custom mapping from replaced versions to full image references, which can either be manually built ourselves or just pointed to the upstream moby/buildkit:master equivalent (but with a digest for stability).
There was a problem hiding this comment.
Did this happen automatically?
There was a problem hiding this comment.
Yeah, which is a bit spooky. I'm not sure what this will mean for the release. I decided to commit it and call it out since we're gonna run into it someday, better to see what happens.
There was a problem hiding this comment.
Yuck, now I get this error when trying to run tests:
core/integration/container_test.go:8:2: module dagger.io/dagger provides package dagger.io/dagger and is replaced but not required; to add it:
go get dagger.io/daggerGo can't seem to decide whether this dependency should exist. 🤔 Or maybe I just broke something. I'll try just adding it back and see if it disappears again.
There was a problem hiding this comment.
So it gets removed when I do go get github.com/moby/buildkit@master.
And then when I go get dagger.io/[email protected] to bring it back, it un-bumps github.com/moby/buildkit to v0.10.5. 😡
Probably because dagger.io/dagger ends up depending on github.com/moby/buildkit and Go actually sees v0.10.1-0.20221027014600-b78713cdd127 => v0.10.5 as a version bump. 😭
There was a problem hiding this comment.
The fix here seems to be to add this line instead:
replace github.com/moby/buildkit => github.com/moby/buildkit v0.10.1-0.20221027014600-b78713cdd127There was a problem hiding this comment.
The fix here seems to be to add this line instead:
If we do that, then I think our SDK users will also need to include that replace, right? 😢
There was a problem hiding this comment.
Yeah, I just ran into that. 🤦♂️
There was a problem hiding this comment.
It sucks, but right now I'm leaning towards just doing it since it's kind of a drop in the bucket, and it'll go away at the same time that we switch to an external engine.
Even without that replace line we'll need to update the docker/docker replace, so they'll already need to do some more copy-pasta.
The alternative of course is to go back to vendoring the filesync implementation.
49ac89e to
63788ac
Compare
|
@shykes @sipsma @aluzzardi This is ready to go now that there's a flag to disable host i/o, but we need to decide how to handle the Buildkit dependency bump. (Or whether to punt for now - see second option.) Unfortunately our dependency cycle makes it impossible to simply bump our It doesn't seem possible to bump Buildkit without bumping it in both members of the dependency cycle at the same time, similar to the trick we pulled with the engine's The first option is to keep the PR as-is, meaning users will need an additional diff --git a/docs/current/partials/_install-sdk-go.md b/docs/current/partials/_install-sdk-go.md
index 367add79..28e93643 100644
--- a/docs/current/partials/_install-sdk-go.md
+++ b/docs/current/partials/_install-sdk-go.md
@@ -6,7 +6,8 @@ From an existing Go module, you can install the Dagger Go SDK using the commands
```shell
go get dagger.io/dagger@latest
-go mod edit -replace github.com/docker/docker=github.com/docker/[email protected]+incompatible
+go mod edit -replace github.com/docker/docker=github.com/docker/[email protected]+incompatible
+go mod edit -replace github.com/moby/buildkit=github.com/moby/[email protected]Pros:
Cons:
The second option is to go back to vendoring our own Pros:
Cons:
The third option is to break the dependency cycle from the engine to the SDK. I took a swing at this and it was kinda sorta doable, but pretty messy. Here's where I stopped. Pros:
Cons:
The fourth option is to bite the bullet and prioritize external engine very soon. I'm pretty interested in pursuing this but I don't have a good idea of our current thinking regarding priorities/timeline/dependencies for this. Pros:
Cons:
I'm sure I missed some pros/cons. This is also all very confusing so please ask if something seems wrong/unclear. There may be other options too. I'm leaning towards the first option since it grants us more flexibility going forward. It's an extra Also good with the second option though for the sake of decoupling this PR from larger more dramatic changes. My only concern is whether we'll want either those changes or newer Buildkit version very soon anyway. I'm going to go rest my brain. |
* copy the entire filesync implementation from BuildKit and change it to just accept direct paths instead of an allowlist of paths * it is no longer required to pre-configure LocalDirs * add Directory.export * remove HostDirectory * change Host.workdir to return a Directory * change Host.directory to take a path and return a Directory Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
* handle github.com/moby/buildkit replace rules in go.mod * support mapping replaced versions to custom images Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
this is the behavior for LocalDirs in upstream Buildkit, and without it synced files end up with funky ownership that causes e.g. git commands to fail with the following error: detected dubious ownership in repository at '<path>' Signed-off-by: Alex Suraci <[email protected]>
currently untested; not totally sure how to do that yet, since exposing it via the client doesn't seem to make sense Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
b64ebd0 to
c36d13e
Compare
|
Any update on the tradeoff here? What is everyone's opinion? |
|
@vito Appreciate you writing this all out and being today's tour guide through dependency hell :-)
I'm so confused by this on so many levels. Where does "v0.10.1" even come from? Why that specific version and not any other? I tried playing around with this too a bit and just became more confused. No response needed, I'm just agreeing that this is very frustrating.
Honestly this is my vote at this immediate moment, just because having support for dynamic localdirs is a blocker on include/exclude, which is being requested a few times a day already. We can just do this for now, then safely make a decision between 1, 3 and 4 afterwards without causing any extra issues on top of what we already have to deal with (afaict, right? correct me if wrong) We will very much just be kicking the can approximately 1 meter down the road rather than solving anything though. I just think decoupling is more important at this point. |
|
Would a live call with the Buildkit / Docker devs help here, to review options? From @cpuguy83 's message on yesterday's community call, I inferred that maybe we could get some support, if we know exactly what to ask for and it's not too disruptive for the Docker community? |
|
I agree with @sipsma that option 2 is the right call as an immediate next step. It doesn't solve the underlying problem, but it doesn't make it worse for our users which is important. Whatever problems it creates for us (dragons) etc are reversible. Not a super strong opinion since I don't have full mastery of the underlying details. |
|
Follow-up: big +1 on optimizing for speed on shipping this feature, even if it means kicking a bunch of cans down the road. This feature is high priority: frequently requested, and also a breaking API change which is time sensitive (earlier is better). Thank you both for pushing this so quickly! |
I don't think that's necessary, the part we're stuck on is a problem of our own that's orthogonal to the docker/docker re: votes for option 2 - works for me! I'll start preparing a vendored edition instead. I too would like to just call this darn thing finished. I'll keep the work I did to support moving ahead to unreleased Buildkit versions in case we want it in the future. |
shykes
left a comment
There was a problem hiding this comment.
Love the feature, big improvement on the API.
Only blocker is the buildkit dependency disaster, which I know is being handled in parallel. Proactively approving :)
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
|
@sipsma Vendored filesync and un-bumped Buildkit, ready to go! |
|
Nicely done. Maybe we should write a guide on local filesystem access, to celebrate the occasion? Any takers @kpenfound @mircubed @vikram-dagger @jpadams @grouville ? Created an issue: #3593 |
I can take this one @shykes. Please lmk who I should coordinate with for technical questions. @grouville, feel free to reassign to me. |
New API (same as #3421):
Note that this includes an extra README.md + NOTICE + BUILDKIT_AUTHORS file for the extracted filesync implementation to preserve copyright attribution.
MAJOR RISK: as soon as we merge this the API will have unfettered read access to the host filesystem. We should understand the implications of this for the Playground, and/or figure out how to make this more secure before merging.