-
Notifications
You must be signed in to change notification settings - Fork 775
Add network endpoint option gw_priority (for moby 28.0) #552
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
Conversation
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.
LGTM but wonder too if we should deprecate the old priority field.
Why introduce |
From the current spec ...
The name I think a field with the original meaning would be a useful thing to add to the API at some point - at the moment, adding a new network connection to a service (or the end of a CLI |
So, if engine brings a new |
Gateway priority influences which network will be used as the container's default gateway (see the PR linked from the description). It's not related to the order in which endpoints are connected. Making the |
I think the two changes in this PR describe all that - if something's still unclear after reading them, I'll make changes. |
How will this be used by |
According to PR description:
This is exactly what compose |
Selection of a default gateway happens every time a network is connected or disconnected, only the current set of network attachments is considered ... it's never had anything to do with the order in which those connections were added. The intention of In the CLI, there's a |
"order in which those connections were added" as describe in the spec just reflect what Compose does, which has no actual effect. It doesn't describe what benefit a user could have from using this feature. MANY expect highest-priority network is assigned to Doesn't mean we should not introduce |
I think this assumption is wrong, and any signs of it in existing issues is actually a symptom for something else… Namely: stable interface names. Users need that for two reasons:
First reason can only ever happen at container start-up, and second is most likely to happen at start-up too. OTOH, the default gateway is a dynamic property of the container. Unlike Compose, the Engine allows (dis)connecting a container to/from a network at runtime, and thus the default gateway might change. Since the temporality isn't the same for both concepts, we decided not to tie them up. When the daemon receives a Of course we could change that, but now let's imagine my container is running a server program and I passed it an argument Now, let's imagine we tie both concepts. What should happen if I want my L3 Btw, note that So, I really think we shouldn't try to tie both aspects. That's why we're going to add support for custom interface names -- see moby/moby#49155. The other reason behind this PR is that I think users should be very explicit if they want a stable ifname. This gives the advantage that you know which interface name matters by looking at the CLI invocation, or at the Compose file. If they don't set it, then the interface name is an implementation detail and they shouldn't rely on it. This also affords us the ability to change the join order at any time. |
Shall we go ahead with this? (If yes, I'll have a go at the compose-go change.) |
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.
LGTM.
+1 on clarifying what priority
actually implies
Example yaml for priority
should not be removed
Please also provide an illustration example for gw_priority
, even this sounds obvious, many just copy/paste those into their compose.yaml file 😅
Signed-off-by: Rob Murray <[email protected]>
Signed-off-by: Rob Murray <[email protected]>
I've put it back ... but without saying what it does (because it doesn't do anything).
Done. |
What this PR does / why we need it:
Add networks.gw_priority
The plan is to hook this up to the
EndpointSettings.GwPriority
field that will be added in moby 28.0, moby/moby#48936Update description of networks.priority
Since docker/compose#11429, Compose includes all network endpoints in the initial create request to the moby API ... the network with the highest priority becomes the "primary" endpoint, but there's no other ordering because the endpoints are passed in a map.
Even before that change, it did not influence moby's selection of a default gateway. It would have influenced the container's device name (they're numbered sequentially when endpoints are added to a container, for example
eth0
eth1
etc), but that ordering was not retained over a container restart.This
priority
field should probably be deprecated, but I'm not sure of the rules for that or how to show it ... happy to update!