summaryrefslogtreecommitdiff
path: root/src/conf_mode/container.py
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-06-28 13:41:07 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-06-28 13:41:07 +0000
commit6ac48a2051a98f4312ca94a3389befd43e74c60e (patch)
tree8acafe4a11fc80471ae192529118f58aaeacda08 /src/conf_mode/container.py
parent49d7ba83958a44b92d80da33cef25ff666a55d7b (diff)
downloadvyos-1x-6ac48a2051a98f4312ca94a3389befd43e74c60e.tar.gz
vyos-1x-6ac48a2051a98f4312ca94a3389befd43e74c60e.zip
containers: T4486: Fix path for removing containers
Fix correct path for removing containers and container networks Reduce timoute from 10 (default) to 3 seconds for stopping containers
Diffstat (limited to 'src/conf_mode/container.py')
-rwxr-xr-xsrc/conf_mode/container.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py
index 2110fd9e0..77281eb4d 100755
--- a/src/conf_mode/container.py
+++ b/src/conf_mode/container.py
@@ -90,10 +90,10 @@ def get_config(config=None):
container['name'][name] = dict_merge(default_values, container['name'][name])
# Delete container network, delete containers
- tmp = node_changed(conf, base + ['container', 'network'])
+ tmp = node_changed(conf, base + ['network'])
if tmp: container.update({'network_remove' : tmp})
- tmp = node_changed(conf, base + ['container', 'name'])
+ tmp = node_changed(conf, base + ['name'])
if tmp: container.update({'container_remove' : tmp})
return container
@@ -270,12 +270,13 @@ def apply(container):
# Option "--force" allows to delete containers with any status
if 'container_remove' in container:
for name in container['container_remove']:
- call(f'podman stop {name}')
+ call(f'podman stop --time 3 {name}')
call(f'podman rm --force {name}')
# Delete old networks if needed
if 'network_remove' in container:
for network in container['network_remove']:
+ call(f'podman network rm {network}')
tmp = f'/etc/cni/net.d/{network}.conflist'
if os.path.exists(tmp):
os.unlink(tmp)
@@ -294,7 +295,7 @@ def apply(container):
# check if there is a container by that name running
tmp = _cmd('podman ps -a --format "{{.Names}}"')
if name in tmp:
- _cmd(f'podman stop {name}')
+ _cmd(f'podman stop --time 3 {name}')
_cmd(f'podman rm --force {name}')
continue