-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Dynamic network configuration via session attachable #3960
Conversation
3dd739f
to
49cff4f
Compare
Couple of questions with this. The first one is regarding how this configuration should participate in the cache and portability/reproducibility guarantees (or should it be for interactive containers only). Is it for global hostnames/IPs or for deployment-specific overrides? If it is global then it should be in the build cache. If not, then it is kind of weird, as client(remote machine) is configuring the network per request via the session, but the IPs it provides require a special configuration of buildkitd. In that case, it should either be configured from buildkitd config, or client should share primitives for actual network forwarding instead of preconfigured IPs. The API could be for backing of a network (tuntap) interface or maybe proxying Wireguard packets and exposing the Wireguard interface in the container. Then client-side would have full control of tweaking the network properties of a step, transfers between steps or client and a step etc. Once we have these primitives it should be possible to have network dependencies in LLB. If the client provides (preconfigured) IPs then the question is as well of how does this work with existing NetworkMode/Entitlements configurations that put things in different network namespaces, meaning their routing is different. |
Some important context: In Dagger, services are content-addressed. Their hostname is a hash of their recipe, kind of like an LLB digest but shorter. This allows client calls like There are two sides of this to explain, since these changes correspond to two different approaches to container-to-container-networking. I started with ExtraHostsTo save some time: we don't need this anymore, and I realized while writing this comment that it's not very useful in its current form. I can just remove it if you want to skip to the next point, since it seems to be the source of most of your concerns so far. To explain anyway: the IP value being passed to This implementation seems hard to use though, because you would need dynamic network IDs to handle each client's hosts config, and you would need the DNSThe DNS use case is similar to #3044. The trick is that we want clients to always resolve hostnames to a service running in the same Dagger session. For example, if you're running two test suites concurrently on the same Buildkit we don't want them accidentally reaching each other's services. With I hope that makes sense; there's a lot of things that have to align for this all to work. Thanks for the review! |
Follow-up: to use Also didn't mean to ignore this:
I don't have enough experience with the tech mentioned here to fully picture the proposal, but I'm very interested in expanding Buildkit's network capabilities so that it feels more integrated compared to my pile of hacks. 😄 |
bfdcefa
to
a7fc1e4
Compare
Added integration tests for Git/HTTP + dynamic DNS config. Not sure why https://github.com/moby/buildkit/actions/runs/5361203707/jobs/9726967877?pr=3960 failed. Maybe a flake? |
eb4bf0d
to
4711702
Compare
Rebased and squashed all the commits to reduce noise. |
Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
still not great, but slightly better Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
Sorry to bump. Is there anything I can do, or any changes I need to make, to help this along? Thanks! Current state: all tests are passing, or were before the most recent suite which seems to have hit a few flakes. Tests have been added, and caps have been added. |
going with the networks package definition. will revert if requested, but seems worth trying. Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
Will this be fixed soon? |
"github.com/pkg/errors" | ||
) | ||
|
||
// gitCLI carries config to pass to the git CLI to make running multiple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vito any chance you could pull this git refactor into a separate PR? I was looking at unifying the buildx and buildkit git helpers into one place, and this would be a good start 🎉
If you're too busy, I'm happy to pick it up 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, pretty in the weeds at the moment but I'll let you know if I find time! Feel free to pick this up in the meantime 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Started hacking on this in #4106 🎉 (thanks!)
Looking at this again, I'll try to clear up what is problematic and what is not. The new The new Session API itself does not need to be defined in upstream if it is too Dagger-specific. You could probably hide the networkConfigID into some metadata where your session implementation could catch it. Or we could add some general-purpose metadata array for that. But this is probably what you are already doing and wished to clean up. Adding the extra DNS info/types directly into LLB is not issue afaics., it is really the session callback that is super specific. Adding new options to the Go library(or config file) that are unused by the upstream use-cases is not that problematic either. It is really the proto library that we need to be careful about. |
Thanks for the feedback! We can just close this anyway. A
Yeah, if I were to start over I would probably just add LLB level DNS config to Exec + HTTP + Git + other sources and ignore it in |
Adds support for passing network config (DNS + ExtraHosts) to
llb.Exec
,llb.Git
, andllb.HTTP
via asession.Attachable
instead of baking it directly into LLB.The use of a
session.Attachable
allows you to configure ephemeral IPs and DNS search domains without busting the cache by passing a stable ID value that is resolved at build time, just like secrets.The end goal is to use this in Dagger, where we're switching service containers to run via the gateway
NewContainer
API instead ofSolve
. We want to use DNS search domains to keep service addresses namespaced to Dagger sessions running against the same Buildkit. With this approach we need a way to pass the search domain to anything that can reach a service, which means not only containers but HTTP and Git sources too.I'm also interested in expanding this in the future to support TLS configuration, and to support configuring it for
llb.Image
too. (Softly related: #3366)Implementation notes:
Exec
support works by merging the provided config into the container's/etc/hosts
and/etc/resolv.conf
, very similar to howllb.ExtraHosts
currently works.HTTP
works using a custom DNS resolver at the HTTP transport layer.llb.Image
in the future.Git
works by unsharing the mount namespace and mounting over/etc/hosts
and/etc/resolv.conf
every time we shell out togit
.git
call.