Skip to content

Commit fa6a6c9

Browse files
committed
feat: Add migration of IPv4-only to Dual Stack
1 parent cbb9777 commit fa6a6c9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

supervisor/docker/network.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,24 @@ def observer(self) -> IPv4Address:
7777
def _get_network(self) -> docker.models.networks.Network:
7878
"""Get supervisor network."""
7979
try:
80-
return self.docker.networks.get(DOCKER_NETWORK)
80+
if (network := self.docker.networks.get(DOCKER_NETWORK))["EnableIPv6"]:
81+
return network
82+
network.remove()
83+
_LOGGER.info("Migrating Supervisor network to IPv4/IPv6 Dual Stack")
8184
except docker.errors.NotFound:
8285
_LOGGER.info("Can't find Supervisor network, creating a new network")
8386

84-
ip6am_pool = docker.types.IPAMPool(subnet=str(DOCKER_IPV6_NETWORK_MASK))
85-
86-
ip4am_pool = docker.types.IPAMPool(
87-
subnet=str(DOCKER_IPV4_NETWORK_MASK),
88-
gateway=str(self.gateway),
89-
iprange=str(DOCKER_IPV4_NETWORK_RANGE),
87+
ipam_config = docker.types.IPAMConfig(
88+
pool_configs=[
89+
docker.types.IPAMPool(subnet=str(DOCKER_IPV6_NETWORK_MASK)),
90+
docker.types.IPAMPool(
91+
subnet=str(DOCKER_IPV4_NETWORK_MASK),
92+
gateway=str(self.gateway),
93+
iprange=str(DOCKER_IPV4_NETWORK_RANGE),
94+
),
95+
]
9096
)
9197

92-
ipam_config = docker.types.IPAMConfig(pool_configs=[ip6am_pool, ip4am_pool])
93-
9498
return self.docker.networks.create(
9599
DOCKER_NETWORK,
96100
driver="bridge",

0 commit comments

Comments
 (0)