summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2025-11-04 17:53:11 +0200
committerGitHub <noreply@github.com>2025-11-04 17:53:11 +0200
commitcc60275ab0db2c45f2ad7387d6a91a96fa9d6337 (patch)
treea59baa904529193481c12fb112a2de29b9d08608 /src/conf_mode
parent6d0324506a5b0419eb0ae001d8d006a414030405 (diff)
parentae6d3437dc3247c396444b7f65eb49a98b0dd800 (diff)
downloadvyos-1x-cc60275ab0db2c45f2ad7387d6a91a96fa9d6337.tar.gz
vyos-1x-cc60275ab0db2c45f2ad7387d6a91a96fa9d6337.zip
Merge pull request #4828 from c-po/restart-container-vrf
container: T7305: fix VRF loss when restarting pods
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/container.py25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py
index a57a9d054..af09ac52a 100755
--- a/src/conf_mode/container.py
+++ b/src/conf_mode/container.py
@@ -29,7 +29,7 @@ from vyos.configdict import dict_merge
from vyos.configdict import node_changed
from vyos.configdict import is_node_changed
from vyos.configverify import verify_vrf
-from vyos.ifconfig import Interface
+from vyos.container import restart_network
from vyos.utils.configfs import delete_cli_node
from vyos.utils.configfs import add_cli_node
from vyos.utils.cpu import get_core_count
@@ -161,7 +161,7 @@ def verify(container):
if 'name_server' in container_config and 'no_name_server' not in container['network'][network_name]:
raise ConfigError(f'Setting name server has no effect when attached container network has DNS enabled!')
- mac = dict_search(f'network.{network_name}.mac', container_config)
+ mac = dict_search(f'network.{network_name}.mac', container_config)
if mac:
if mac in net_dict['mac'].keys():
raise ConfigError(f'MAC address "{mac}" is already used by container "{net_dict["mac"][mac]}"!')
@@ -194,7 +194,7 @@ def verify(container):
if ip_address(address) == ip_network(network)[1]:
raise ConfigError(f'IP address "{address}" can not be used for a container, ' \
'reserved for the container engine!')
-
+
if address in net_dict['address'].keys():
raise ConfigError(f'IP address "{address}" is already used by container "{net_dict["address"][address]}"!')
net_dict['address'][address] = name
@@ -673,23 +673,8 @@ def apply(container):
if disabled_new:
call('systemctl daemon-reload')
- # Start network and assign it to given VRF if requested. this can only be done
- # after the containers got started as the podman network interface will
- # only be enabled by the first container and yet I do not know how to enable
- # the network interface in advance
- if 'network' in container:
- for network, network_config in container['network'].items():
- type_config = dict_search('type', network_config)
- if not dict_search('macvlan', type_config):
- network_name = f'pod-{network}'
- # T5147: Networks are started only as soon as there is a consumer.
- # If only a network is created in the first place, no need to assign
- # it to a VRF as there's no consumer, yet.
- if interface_exists(network_name):
- tmp = Interface(network_name)
- tmp.set_vrf(network_config.get('vrf', ''))
- tmp.add_ipv6_eui64_address('fe80::/64')
-
+ # Re-Start network and assign it to given VRF if requested.
+ restart_network(container)
return None