diff options
| author | Daniil Baturin <daniil@vyos.io> | 2025-10-30 14:41:53 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-30 14:41:53 +0000 |
| commit | 524a91424b9bc4e4b3963c049422fe689b60ec38 (patch) | |
| tree | f515cbb80f6909c570ede69025e6dcfcbcfe37e7 /src | |
| parent | 449f3d4dbf1f55a7cfcd8ecf450f9ebc93188d97 (diff) | |
| parent | bd3070477804ed03e356d95e8c619fe7580b9231 (diff) | |
| download | vyos-1x-524a91424b9bc4e4b3963c049422fe689b60ec38.tar.gz vyos-1x-524a91424b9bc4e4b3963c049422fe689b60ec38.zip | |
Merge pull request #4702 from nvollmar/T6686
T6686: adds container health checks
Diffstat (limited to 'src')
| -rwxr-xr-x | src/conf_mode/container.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py index b8c3d3d0c..a57a9d054 100755 --- a/src/conf_mode/container.py +++ b/src/conf_mode/container.py @@ -479,6 +479,24 @@ def generate_run_arguments(name, container_config, host_ident): entrypoint = json_write(container_config['entrypoint'].split()).replace('"', """) entrypoint = f'--entrypoint '{entrypoint}'' + healthcheck = ' --no-healthcheck' + if 'health_check' in container_config: + healthcheck = '' + if 'command' in container_config['health_check']: + health_cmd = container_config['health_check']['command'] + healthcheck += f' --health-cmd="{health_cmd}"' + if 'interval' in container_config['health_check']: + health_int = container_config['health_check']['interval'] + if health_int != 'disable': + health_int = f'{health_int}s' + healthcheck += f' --health-interval={health_int}' + if 'timeout' in container_config['health_check']: + health_to = container_config['health_check']['timeout'] + healthcheck += f' --health-timeout={health_to}s' + if 'retry' in container_config['health_check']: + health_rt = container_config['health_check']['retry'] + healthcheck += f' --health-retries={health_rt}' + command = '' if 'command' in container_config: command = container_config['command'].strip() @@ -488,7 +506,7 @@ def generate_run_arguments(name, container_config, host_ident): command_arguments = container_config['arguments'].strip() if 'allow_host_networks' in container_config: - return f'{container_base_cmd} --net host {entrypoint} {image} {command} {command_arguments}'.strip() + return f'{container_base_cmd} {healthcheck} --net host {entrypoint} {image} {command} {command_arguments}'.strip() ip_param = '' addr_info = '' @@ -520,7 +538,7 @@ def generate_run_arguments(name, container_config, host_ident): delete_cli_node(mac_config_path) add_cli_node(mac_config_path, value=mac_add) - return f'{container_base_cmd} --no-healthcheck --net {networks} {ip_param} {mac_address} {entrypoint} {image} {command} {command_arguments}'.strip() + return f'{container_base_cmd} {healthcheck} --net {networks} {ip_param} {mac_address} {entrypoint} {image} {command} {command_arguments}'.strip() def generate(container): |
