moby / swarmkit

A toolkit for orchestrating distributed systems at any scale. It includes primitives for node discovery, raft-based consensus, task scheduling and more.
Apache License 2.0
3.35k stars 614 forks source link

Subnet overlap error is ignored #2398

Open mavenugo opened 7 years ago

mavenugo commented 7 years ago

When I create 2 networks with overlapping subnets, the allocator fails as expected. But the error is consumed at swarmkit and hence the network is created in inconsistent state (the driver field is empty). In the example below, the wtnet2's driver is not overlay and the daemon logs shows the subnet overlap error.

root@Ubuntu-vm ~ $ docker network create -d overlay --subnet=10.10.0.0/16 wtnet
bm52fabktkk5p5gddsbdf0vwp
root@Ubuntu-vm ~ $ docker network ls | grep wtnet
bm52fabktkk5        wtnet              overlay             swarm

root@Ubuntu-vm ~ $ docker network create -d overlay --subnet=10.10.1.0/24 wtnet2
rgk301uv83vj3p9ac5nqdw4l4
root@Ubuntu-vm ~ $ docker network ls | grep wtnet
bm52fabktkk5        wtnet              overlay             swarm
rgk301uv83vj        wtnet2                                 swarm
DEBU[21843] RequestPool(GlobalDefault, 10.10.1.0/24, , map[], false)
ERRO[21843] Failed allocation for network rgk301uv83vj3p9ac5nqdw4l4  error="failed during network allocation for network rgk301uv83vj3p9ac5nqdw4l4: failed allocating pools and gateway IP for network rgk301uv83vj3p9ac5nqdw4l4: Pool overlaps with other one on this address space" module=node node.id=2ojtm3zuylbi4osers2frp50e

The error must be pushed back to the control-api and the network should be removed from the raft-store and the error is clearly displayed synchronously to the user.

thaJeztah commented 7 years ago

Linking a moby issue that may have the same cause as this one (based on the driver being empty); https://github.com/moby/moby/issues/35099