summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-03-28 21:53:07 +0200
committerChristian Breunig <christian@breunig.cc>2023-03-28 21:53:07 +0200
commit52e51ffbb84996aee9d5b94eebf64589ead31225 (patch)
tree3dbfca340af4e2b61ee9758a5664b39c7ad20cd2 /src/conf_mode
parent4a58a27adad59f19c7d14d0b9753259baed011f4 (diff)
downloadvyos-1x-52e51ffbb84996aee9d5b94eebf64589ead31225.tar.gz
vyos-1x-52e51ffbb84996aee9d5b94eebf64589ead31225.zip
container: T5047: restart only containers that changed
By default VyOS used to restart all containers it managed. This makes no sense as it will be service disrupting. Instead only restart the containers that had changes on the CLI beeing made.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/container.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py
index 44c9b74da..bf83416b2 100755
--- a/src/conf_mode/container.py
+++ b/src/conf_mode/container.py
@@ -24,8 +24,10 @@ from vyos.base import Warning
from vyos.config import Config
from vyos.configdict import dict_merge
from vyos.configdict import node_changed
+from vyos.configdict import is_node_changed
from vyos.util import call
from vyos.util import cmd
+from vyos.util import dict_search
from vyos.util import run
from vyos.util import rc_cmd
from vyos.util import write_file
@@ -84,6 +86,15 @@ def get_config(config=None):
for name in container['name']:
container['name'][name] = dict_merge(default_values, container['name'][name])
+ # T5047: Any container related configuration changed? We only
+ # wan't to restart the required containers and not all of them ...
+ tmp = is_node_changed(conf, base + ['name', name])
+ if tmp:
+ if 'container_restart' not in container:
+ container['container_restart'] = [name]
+ else:
+ container['container_restart'].append(name)
+
# XXX: T2665: we can not safely rely on the defaults() when there are
# tagNodes in place, it is better to blend in the defaults manually.
if 'port' in container['name'][name]:
@@ -448,7 +459,8 @@ def apply(container):
os.unlink(file_path)
continue
- cmd(f'systemctl restart vyos-container-{name}.service')
+ if name in dict_search('container_restart', container):
+ cmd(f'systemctl restart vyos-container-{name}.service')
if disabled_new:
call('systemctl daemon-reload')