Fix podman healtcheck when not enabled
There was a bug where setting the test command for the health check to 'NONE' would throw an error in podman_worker. This was problematic since K-A uses 'NONE' as an indicator that the health check is not enabled. Closes-Bug: #2071912 Change-Id: I3140bb79eace58b23f579be3da569c502c52c38c Signed-off-by: Ivan Halomi <ivan.halomi@tietoevry.com>
This commit is contained in:
parent
4ed5f7537d
commit
59bebd41eb
@ -104,7 +104,8 @@ class PodmanWorker(ContainerWorker):
|
|||||||
if healthcheck:
|
if healthcheck:
|
||||||
healthcheck = self.parse_healthcheck(healthcheck)
|
healthcheck = self.parse_healthcheck(healthcheck)
|
||||||
self.params.pop('healthcheck', None)
|
self.params.pop('healthcheck', None)
|
||||||
args.update(healthcheck)
|
if healthcheck:
|
||||||
|
args.update(healthcheck)
|
||||||
|
|
||||||
# getting dimensions into separate parameters
|
# getting dimensions into separate parameters
|
||||||
dimensions = self.params.get('dimensions')
|
dimensions = self.params.get('dimensions')
|
||||||
|
6
releasenotes/notes/bug-2071912-89d2fba8865ddf40.yaml
Normal file
6
releasenotes/notes/bug-2071912-89d2fba8865ddf40.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes podman failure when enable_container_healthchecks
|
||||||
|
is set to "no".
|
||||||
|
`LP#2071912 <https://launchpad.net/bugs/2071912>`__
|
@ -365,6 +365,21 @@ class TestContainer(base.BaseTestCase):
|
|||||||
self.dw.dc.create_container.assert_called_once_with(
|
self.dw.dc.create_container.assert_called_once_with(
|
||||||
**{k: self.fake_data['params'][k] for k in expected_args})
|
**{k: self.fake_data['params'][k] for k in expected_args})
|
||||||
|
|
||||||
|
def test_create_container_with_None_healthcheck(self):
|
||||||
|
self.fake_data['params']['healthcheck'] = \
|
||||||
|
{'test': ['NONE']}
|
||||||
|
self.dw = get_DockerWorker(self.fake_data['params'])
|
||||||
|
self.dw.dc.create_host_config = mock.MagicMock(
|
||||||
|
return_value=self.fake_data['params']['host_config'])
|
||||||
|
self.dw.create_container()
|
||||||
|
inject_env_when_create_container(self.fake_data['params'])
|
||||||
|
self.assertTrue(self.dw.changed)
|
||||||
|
expected_args = {'command', 'detach', 'environment', 'host_config',
|
||||||
|
'image', 'labels', 'name', 'tty',
|
||||||
|
'volumes'}
|
||||||
|
self.dw.dc.create_container.assert_called_once_with(
|
||||||
|
**{k: self.fake_data['params'][k] for k in expected_args})
|
||||||
|
|
||||||
def test_create_container_with_tmpfs(self):
|
def test_create_container_with_tmpfs(self):
|
||||||
self.fake_data['params']['tmpfs'] = ['/tmp'] # nosec: B108
|
self.fake_data['params']['tmpfs'] = ['/tmp'] # nosec: B108
|
||||||
self.dw = get_DockerWorker(self.fake_data['params'])
|
self.dw = get_DockerWorker(self.fake_data['params'])
|
||||||
|
@ -246,6 +246,18 @@ class TestContainer(base.BaseTestCase):
|
|||||||
self.assertIsNotNone(hc_call)
|
self.assertIsNotNone(hc_call)
|
||||||
self.assertEqual(hc, hc_call)
|
self.assertEqual(hc, hc_call)
|
||||||
|
|
||||||
|
def test_create_container_with_None_healthcheck(self):
|
||||||
|
hc = {'test': ['NONE']}
|
||||||
|
self.fake_data['params']['healthcheck'] = hc
|
||||||
|
self.pw = get_PodmanWorker(self.fake_data['params'].copy())
|
||||||
|
|
||||||
|
self.pw.create_container()
|
||||||
|
self.assertTrue(self.pw.changed)
|
||||||
|
podman_create_kwargs = self.pw.pc.containers.create.call_args.kwargs
|
||||||
|
hc_call = podman_create_kwargs.get('healthcheck', None)
|
||||||
|
self.pw.pc.containers.create.assert_called_once()
|
||||||
|
self.assertIsNone(hc_call)
|
||||||
|
|
||||||
@unittest.skip("Skipping because tmpfs is currently"
|
@unittest.skip("Skipping because tmpfs is currently"
|
||||||
" not supported by podman API.")
|
" not supported by podman API.")
|
||||||
def test_create_container_with_tmpfs(self):
|
def test_create_container_with_tmpfs(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user