summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-04-01 15:44:04 +0200
committerGitHub <noreply@github.com>2023-04-01 15:44:04 +0200
commite890a70d134fc63507ec396f9b7d4290df1cc0cb (patch)
tree7edcc3e88f1f63897f9458b94189089719087513 /src/conf_mode
parent589e25721b4df2fceaafd9946dc0c3ccbc37d8d9 (diff)
parent39c8d271b388588905e2a0584fafe180b2c76d9a (diff)
downloadvyos-1x-e890a70d134fc63507ec396f9b7d4290df1cc0cb.tar.gz
vyos-1x-e890a70d134fc63507ec396f9b7d4290df1cc0cb.zip
Merge pull request #1919 from c-po/equuleus
container: T5047: restart only containers that changed (backport)
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/container.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py
index 10e9e9213..50c3424d2 100755
--- a/src/conf_mode/container.py
+++ b/src/conf_mode/container.py
@@ -25,8 +25,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 write_file
from vyos.template import inc_ip
@@ -80,6 +82,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]:
@@ -412,7 +423,9 @@ def apply(container):
os.unlink(file_path)
continue
- cmd(f'systemctl restart vyos-container-{name}.service')
+ tmp = dict_search('container_restart', container)
+ if tmp and name in tmp:
+ cmd(f'systemctl restart vyos-container-{name}.service')
if disabled_new:
call('systemctl daemon-reload')