-
Notifications
You must be signed in to change notification settings - Fork 390
T6686: adds container health checks #4702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: current
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -556,6 +556,67 @@ | |
</properties> | ||
<defaultValue>journald</defaultValue> | ||
</leafNode> | ||
<node name="health-check"> | ||
<properties> | ||
<help>Configure health check for the container</help> | ||
</properties> | ||
<children> | ||
<leafNode name="disable"> | ||
<properties> | ||
<help>Disable health check if container has one defined</help> | ||
<valueless/> | ||
</properties> | ||
</leafNode> | ||
<leafNode name="command"> | ||
<properties> | ||
<help>Health check command to run for the container</help> | ||
</properties> | ||
</leafNode> | ||
<leafNode name="interval"> | ||
<properties> | ||
<help>Interval for the health checks</help> | ||
<completionHelp> | ||
<list>disable</list> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An interval that is not defined on the CLI should count as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The situation is a bit more complex. Container can define health checks including intervals etc. Podman by default will run them as defined by the image. So all the config options here are overrides if the image defines them already. And the disable option is there to explicitly also disable pre-defined health checks. |
||
</completionHelp> | ||
<valueHelp> | ||
<format>disable</format> | ||
<description>Run health checks manually</description> | ||
</valueHelp> | ||
<valueHelp> | ||
<format>u32:1-16384</format> | ||
<description>Time in seconds</description> | ||
</valueHelp> | ||
<constraint> | ||
<validator name="numeric" argument="--range 1-16384"/> | ||
</constraint> | ||
</properties> | ||
</leafNode> | ||
<leafNode name="timeout"> | ||
<properties> | ||
<help>Timeout for the health check to complete</help> | ||
<valueHelp> | ||
<format>u32:1-16384</format> | ||
<description>Time in seconds</description> | ||
</valueHelp> | ||
<constraint> | ||
<validator name="numeric" argument="--range 1-16384"/> | ||
</constraint> | ||
</properties> | ||
</leafNode> | ||
<leafNode name="retries"> | ||
<properties> | ||
<help>The number of retries before container is consider unhealthy</help> | ||
nvollmar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<valueHelp> | ||
<format>0</format> | ||
<description>No retry</description> | ||
</valueHelp> | ||
<constraint> | ||
<validator name="numeric" argument="--range 0-255"/> | ||
</constraint> | ||
</properties> | ||
</leafNode> | ||
</children> | ||
</node> | ||
</children> | ||
</tagNode> | ||
<tagNode name="network"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -462,6 +462,25 @@ def generate_run_arguments(name, container_config, host_ident): | |
entrypoint = json_write(container_config['entrypoint'].split()).replace('"', """) | ||
entrypoint = f'--entrypoint '{entrypoint}'' | ||
|
||
healthcheck = '' | ||
if 'health_check' in container_config: | ||
nvollmar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 'retries' in container_config['health_check']: | ||
health_rt = container_config['health_check']['retries'] | ||
healthcheck += f' --health-retries={health_rt}' | ||
if 'disable' in container_config['health_check']: | ||
healthcheck = f' --no-healthcheck' | ||
|
||
command = '' | ||
if 'command' in container_config: | ||
command = container_config['command'].strip() | ||
|
@@ -471,7 +490,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 = '' | ||
|
@@ -489,7 +508,7 @@ def generate_run_arguments(name, container_config, host_ident): | |
|
||
mac_address = f'--mac-address {gen_mac(name, addr_info, host_ident)}' | ||
|
||
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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default behaviour is changed, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue here is, the |
||
|
||
|
||
def generate(container): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a generic XML building block for the disable CLI option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the semantics are different I'd keep the custom help text here.