summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-11-04 20:41:28 +0100
committerChristian Poessinger <christian@poessinger.com>2021-11-04 20:41:30 +0100
commit358f0b481d8620cad4954e3fe418054b9a8c3ecd (patch)
treed563ad97011e2b9755522504cd9168500c477e11 /src/conf_mode
parentd54a3213d304e40a2503df609c72f2e508daf6c3 (diff)
downloadvyos-1x-358f0b481d8620cad4954e3fe418054b9a8c3ecd.tar.gz
vyos-1x-358f0b481d8620cad4954e3fe418054b9a8c3ecd.zip
containers: T2216: bugfix config error on image upgrade
As it takes time for the OS to settle while booting up the first time a container is started after image upgrade it will fail big time. To prevent this we try to start the container up to 10 times before we generate a hard error. This makes error-free image upgrade possible again when using containers.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/containers.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/conf_mode/containers.py b/src/conf_mode/containers.py
index 4511eb7e9..20b84b858 100755
--- a/src/conf_mode/containers.py
+++ b/src/conf_mode/containers.py
@@ -237,17 +237,6 @@ def apply(container):
if os.path.exists(tmp):
os.unlink(tmp)
- service_name = 'podman.service'
- if 'network' in container or 'name' in container:
- # Start podman if it's required and not yet running
- if not is_systemd_service_active(service_name):
- _cmd(f'systemctl start {service_name}')
- # Wait for podman to be running
- while not is_systemd_service_running(service_name):
- sleep(0.250)
- else:
- _cmd(f'systemctl stop {service_name}')
-
# Add container
if 'name' in container:
for name, container_config in container['name'].items():
@@ -318,7 +307,17 @@ def apply(container):
if 'address' in container_config['network'][network]:
address = container_config['network'][network]['address']
ipparam = f'--ip {address}'
- _cmd(f'{container_base_cmd} --net {network} {ipparam} {image}')
+
+ counter = 0
+ while True:
+ if counter >= 10:
+ break
+ try:
+ _cmd(f'{container_base_cmd} --net {network} {ipparam} {image}')
+ break
+ except:
+ counter = counter +1
+ sleep(0.5)
return None