Skip to content

Commit

Permalink
add support for on failure actions in healthchecks
Browse files Browse the repository at this point in the history
podman recently added support for failure actions in healthchecks.
Support these by exposing the specgen entity

Signed-off-by: Charlie Doern <[email protected]>
  • Loading branch information
cdoern committed Oct 3, 2022
1 parent 2605c6c commit 81b2cac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions podman/domain/containers_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def create(
process will run as.
healthcheck (Dict[str,Any]): Specify a test to perform to check that the
container is healthy.
health_check_on_failure_action (int): Specify an action if a healthcheck fails.
hostname (str): Optional hostname for the container.
init (bool): Run an init inside the container that forwards signals and reaps processes
init_path (str): Path to the docker-init binary
Expand Down Expand Up @@ -371,6 +372,7 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
"expose": {},
"groups": pop("group_add"),
"healthconfig": pop("healthcheck"),
"health_check_on_failure_action": pop("health_check_on_failure_action"),
"hostadd": [],
"hostname": pop("hostname"),
"httpproxy": pop("use_config_proxy"),
Expand Down
8 changes: 8 additions & 0 deletions podman/tests/integration/test_container_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ def __get_expected_value(container_p, host_p):
)
)

def test_container_healtchecks(self):
"""Test passing various healthcheck options"""
parameters = {}
parameters['healthcheck'] = {'Test': ['CMD-SHELL curl http://localhost || exit']}
parameters['health_check_on_failure_action'] = 1
container = self.client.containers.create(self.alpine_image, **parameters)
self.containers.append(container)

def test_container_mem_limit(self):
"""Test passing memory limit"""
self._test_memory_limit('mem_limit', 'Memory')
Expand Down

0 comments on commit 81b2cac

Please sign in to comment.