summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-11-02 09:30:05 +0100
committerChristian Breunig <christian@breunig.cc>2025-11-03 21:09:14 +0100
commitae6d3437dc3247c396444b7f65eb49a98b0dd800 (patch)
tree79b3e008ad916e476c67eea1af327ddcfd67552c /src/op_mode
parentf61656f9a0010498b1778c43a599862e84250b7d (diff)
downloadvyos-1x-ae6d3437dc3247c396444b7f65eb49a98b0dd800.tar.gz
vyos-1x-ae6d3437dc3247c396444b7f65eb49a98b0dd800.zip
container: T7305: fix VRF loss when restarting pods
Container networks are only started when there is at least one active consumer. If a network is created without any attached containers, it does not need to be assigned to a VRF yet. When the last container in a pod is stopped, its associated container network is removed. Upon container restart, the kernel recreates the network, but the VRF assignment may be lost in the process. This change ensures that all container networks are correctly reattached to their designated VRFs when a pod restarts.
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/container.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/op_mode/container.py b/src/op_mode/container.py
index a34901cb4..281c95e2c 100755
--- a/src/op_mode/container.py
+++ b/src/op_mode/container.py
@@ -166,6 +166,8 @@ def show_network(raw: bool):
def restart(name: str):
from vyos.utils.process import rc_cmd
+ from vyos.config import Config
+ from vyos.container import restart_network
rc, output = rc_cmd(f'systemctl restart vyos-container-{name}.service')
if rc != 0:
@@ -173,6 +175,13 @@ def restart(name: str):
if rc2 != 0:
print(output)
return None
+ if rc == 0:
+ conf = Config()
+ container = conf.get_config_dict(['container'], key_mangling=('-', '_'),
+ no_tag_node_value_mangle=True,
+ get_first_key=True,
+ with_recursive_defaults=True)
+ restart_network(container)
print(f'Container "{name}" restarted!')
return output