Dynamic network configuration via session attachable#3960
Dynamic network configuration via session attachable#3960vito wants to merge 3 commits intomoby:masterfrom
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.
@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.
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 🙏
|
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.HTTPvia asession.Attachableinstead of baking it directly into LLB.The use of a
session.Attachableallows 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
NewContainerAPI 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.Imagetoo. (Softly related: #3366)Implementation notes:
Execsupport works by merging the provided config into the container's/etc/hostsand/etc/resolv.conf, very similar to howllb.ExtraHostscurrently works.HTTPworks using a custom DNS resolver at the HTTP transport layer.llb.Imagein the future.Gitworks by unsharing the mount namespace and mounting over/etc/hostsand/etc/resolv.confevery time we shell out togit.gitcall.