Don't enforce new validation rules for existing networks#47361
Don't enforce new validation rules for existing networks#47361thaJeztah merged 2 commits intomoby:masterfrom
Conversation
corhere
left a comment
There was a problem hiding this comment.
I now see how newly-created networks are always validated before passed to Swarmkit: the (*Daemon).createNetwork(agent=false) flow runs as usual, all the way up to the (*Controller).NewNetwork() call. Libnetwork notices that it's a Swarm-scope network and returns libnetwork.ManagerRedirectError, and the caller creates the network in the Swarm state instead.
moby/api/server/router/network/network_routes.go
Lines 202 to 231 in 7cb1efe
In light of this I am okay with your fix as-is, under one condition: a comment is added in func (*networkRouter) postNetworkCreate which calls out that the n.backend.CreateNetwork(create) call is necessary for validating the network spec for Swarm-scoped networks, despite not actually creating the network. I'm just a bit worried that we might accidentally regress with an overzealous libnetwork refactoring, given how surprising the control flow is.
daemon/network.go
Outdated
| // agent networks here, swarm networks will continue to work too. (New overlay | ||
| // networks are initially created as !agent, so they are still validated.) |
There was a problem hiding this comment.
When a swarm-scoped network is created it is run through createNetwork with !agent, but the network is not actually created by the createNetwork call. And this is true for all swarm-scoped networks irrespective of driver, not just overlay. (#32981)
Non-swarm networks created before network-creation-time validation was added in 25.0.0 continued working, because the checks are not re-run. But, swarm creates networks when needed (with 'agent=true'), to ensure they exist on each agent - ignoring the NetworkNameError that says the network already existed. By ignoring validation errors on creation of a network with agent=true, pre-existing swarm networks with IPAM config that would fail the new checks will continue to work too. New swarm (overlay) networks are still validated, because they are initially created with 'agent=false'. Signed-off-by: Rob Murray <rob.murray@docker.com>
Signed-off-by: Rob Murray <rob.murray@docker.com>
73a4606 to
a26c953
Compare
|
Thank you @corhere, I've made those updates. |
- What I did
Non-swarm networks created before validation checks were added on network creation (#45759) continued working in 25.0.x because the checks were not re-run.
But, a swarm network with invalid IPAM config (for example, subnet
10.0.0.1/24) fails to initialise on upgrade to 25.0.x.Fixes #47331
- How I did it
Swarm creates networks (with
agent=true) to ensure they exist on each agent, when needed - ignoring the NetworkNameError that says the network already existed.By ignoring IPAM validation errors on creation of a network with
agent=true, pre-existing swarm networks with IPAM config that would fail the new checks will continue to work too.New swarm (overlay) networks are still validated, because they are initially created with 'agent=false'.
- How to verify it
As described in #47331 ...
Start with a 24.0.x build:
The service failed to start, logging errors like this ...
With this change, the service starts, and log lines like this are generated ("ingress" is configured as above, "oln" is a non-ingress overlay network) ...
It's not possible to create new overlay and bridge networks with the same issue ...
- Description for the changelog
Do not enforce new validation rules for existing swarm networks