Introduce paunch apply --healthcheck-disabled
Allow an operator to disable the container healtcheck mechanism, when
podman is enabled.
It's done by an option to paunch apply: --healthcheck-disabled
Change-Id: Ic3dd492405b11ec482ff86e1513149c3eceb370f
(cherry picked from commit 817c243d44
)
This commit is contained in:
parent
9c73429503
commit
086209da64
@ -26,7 +26,7 @@ __version__ = pbr.version.VersionInfo('paunch').version_string()
|
||||
|
||||
def apply(config_id, config, managed_by, labels=None, cont_cmd='podman',
|
||||
default_runtime=None, log_level=None, log_file=None,
|
||||
cont_log_path=None):
|
||||
cont_log_path=None, healthcheck_disabled=False):
|
||||
"""Execute supplied container configuration.
|
||||
|
||||
:param str config_id: Unique config ID, should not be re-used until any
|
||||
@ -44,6 +44,8 @@ def apply(config_id, config, managed_by, labels=None, cont_cmd='podman',
|
||||
:param str log_file: optional log file for messages
|
||||
:param str cont_log_path: optional log path for containers. Works only for
|
||||
podman engine. Must be an absolute path.
|
||||
:param bool healthcheck_disabled: optional boolean to disable container
|
||||
healthcheck.
|
||||
|
||||
:returns (list, list, int) lists of stdout and stderr for each execution,
|
||||
and a single return code representing the
|
||||
@ -63,7 +65,8 @@ def apply(config_id, config, managed_by, labels=None, cont_cmd='podman',
|
||||
runner=r,
|
||||
labels=labels,
|
||||
log=log,
|
||||
cont_log_path=cont_log_path
|
||||
cont_log_path=cont_log_path,
|
||||
healthcheck_disabled=healthcheck_disabled
|
||||
)
|
||||
else:
|
||||
r = runner.DockerRunner(managed_by, cont_cmd=cont_cmd, log=log)
|
||||
|
@ -25,7 +25,7 @@ from paunch.utils import systemd
|
||||
class BaseBuilder(object):
|
||||
|
||||
def __init__(self, config_id, config, runner, labels, log=None,
|
||||
cont_log_path=None):
|
||||
cont_log_path=None, healthcheck_disabled=False):
|
||||
self.config_id = config_id
|
||||
self.config = config
|
||||
self.labels = labels
|
||||
@ -33,6 +33,7 @@ class BaseBuilder(object):
|
||||
# Leverage pre-configured logger
|
||||
self.log = log or common.configure_logging(__name__)
|
||||
self.cont_log_path = cont_log_path
|
||||
self.healthcheck_disabled = healthcheck_disabled
|
||||
|
||||
def apply(self):
|
||||
|
||||
@ -108,7 +109,8 @@ class BaseBuilder(object):
|
||||
systemd.service_create(container=container_name,
|
||||
cconfig=cconfig,
|
||||
log=self.log)
|
||||
if 'healthcheck' in cconfig:
|
||||
if (not self.healthcheck_disabled and
|
||||
'healthcheck' in cconfig):
|
||||
check = cconfig.get('healthcheck')['test']
|
||||
systemd.healthcheck_create(container=container_name,
|
||||
log=self.log, test=check)
|
||||
|
@ -18,9 +18,10 @@ from paunch.builder import base
|
||||
class PodmanBuilder(base.BaseBuilder):
|
||||
|
||||
def __init__(self, config_id, config, runner, labels=None, log=None,
|
||||
cont_log_path=None):
|
||||
cont_log_path=None, healthcheck_disabled=False):
|
||||
super(PodmanBuilder, self).__init__(config_id, config, runner,
|
||||
labels, log, cont_log_path)
|
||||
labels, log, cont_log_path,
|
||||
healthcheck_disabled)
|
||||
|
||||
def container_run_args(self, cmd, container):
|
||||
cconfig = self.config[container]
|
||||
|
@ -72,6 +72,13 @@ class Apply(command.Command):
|
||||
help=('Absolute directory path for container log. Works only for '
|
||||
'podman container engine')
|
||||
)
|
||||
parser.add_argument(
|
||||
'--healthcheck-disabled',
|
||||
dest='healthcheck_disabled',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=('Whether or not we disable the containers healthchecks')
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -93,7 +100,8 @@ class Apply(command.Command):
|
||||
cont_cmd=parsed_args.default_runtime,
|
||||
log_level=log_level,
|
||||
log_file=log_file,
|
||||
cont_log_path=parsed_args.cont_log_path
|
||||
cont_log_path=parsed_args.cont_log_path,
|
||||
healthcheck_disabled=parsed_args.healthcheck_disabled
|
||||
)
|
||||
|
||||
return rc
|
||||
|
@ -24,12 +24,14 @@ from paunch.utils import systemd
|
||||
|
||||
|
||||
class BaseRunner(object):
|
||||
def __init__(self, managed_by, cont_cmd, log=None, cont_log_path=None):
|
||||
def __init__(self, managed_by, cont_cmd, log=None, cont_log_path=None,
|
||||
healthcheck_disabled=False):
|
||||
self.managed_by = managed_by
|
||||
self.cont_cmd = cont_cmd
|
||||
# Leverage pre-configured logger
|
||||
self.log = log or common.configure_logging(__name__)
|
||||
self.cont_log_path = cont_log_path
|
||||
self.healthcheck_disabled = healthcheck_disabled
|
||||
if self.cont_cmd == 'docker':
|
||||
self.log.warning('docker runtime is deprecated in Stein '
|
||||
'and will be removed in Train.')
|
||||
@ -282,10 +284,10 @@ class DockerRunner(BaseRunner):
|
||||
class PodmanRunner(BaseRunner):
|
||||
|
||||
def __init__(self, managed_by, cont_cmd=None, log=None,
|
||||
cont_log_path=None):
|
||||
cont_log_path=None, healthcheck_disabled=False):
|
||||
cont_cmd = cont_cmd or 'podman'
|
||||
super(PodmanRunner, self).__init__(managed_by, cont_cmd, log,
|
||||
cont_log_path)
|
||||
cont_log_path, healthcheck_disabled)
|
||||
|
||||
def rename_container(self, container, name):
|
||||
# TODO(emilien) podman doesn't support rename, we'll handle it
|
||||
@ -338,6 +340,7 @@ class PodmanRunner(BaseRunner):
|
||||
runner=self,
|
||||
labels=None,
|
||||
log=self.log,
|
||||
cont_log_path=self.cont_log_path
|
||||
cont_log_path=self.cont_log_path,
|
||||
healthcheck_disabled=self.healthcheck_disabled
|
||||
)
|
||||
builder.apply()
|
||||
|
@ -108,7 +108,8 @@ class TestPaunchPodmanRuntime(base.TestCase):
|
||||
managed_by='tester',
|
||||
labels=None,
|
||||
cont_cmd='podman',
|
||||
cont_log_path=None)
|
||||
cont_log_path=None,
|
||||
healthcheck_disabled=False)
|
||||
runner.assert_called_once_with('tester', cont_cmd='podman',
|
||||
log=mock.ANY)
|
||||
builder.assert_called_once_with(
|
||||
@ -117,7 +118,8 @@ class TestPaunchPodmanRuntime(base.TestCase):
|
||||
runner=runner.return_value,
|
||||
labels=None,
|
||||
log=mock.ANY,
|
||||
cont_log_path=None
|
||||
cont_log_path=None,
|
||||
healthcheck_disabled=False
|
||||
)
|
||||
builder.return_value.apply.assert_called_once_with()
|
||||
|
||||
@ -130,7 +132,8 @@ class TestPaunchPodmanRuntime(base.TestCase):
|
||||
managed_by='tester',
|
||||
labels=None,
|
||||
cont_cmd='podman',
|
||||
cont_log_path='/var/log')
|
||||
cont_log_path='/var/log',
|
||||
healthcheck_disabled=False)
|
||||
runner.assert_called_once_with('tester', cont_cmd='podman',
|
||||
log=mock.ANY)
|
||||
builder.assert_called_once_with(
|
||||
@ -139,7 +142,8 @@ class TestPaunchPodmanRuntime(base.TestCase):
|
||||
runner=runner.return_value,
|
||||
labels=None,
|
||||
log=mock.ANY,
|
||||
cont_log_path='/var/log'
|
||||
cont_log_path='/var/log',
|
||||
healthcheck_disabled=False
|
||||
)
|
||||
builder.return_value.apply.assert_called_once_with()
|
||||
|
||||
@ -152,7 +156,8 @@ class TestPaunchPodmanRuntime(base.TestCase):
|
||||
managed_by='tester',
|
||||
labels={'bink': 'boop'},
|
||||
cont_cmd='podman',
|
||||
cont_log_path=None)
|
||||
cont_log_path=None,
|
||||
healthcheck_disabled=False)
|
||||
|
||||
runner.assert_called_once_with('tester', cont_cmd='podman',
|
||||
log=mock.ANY)
|
||||
@ -162,7 +167,8 @@ class TestPaunchPodmanRuntime(base.TestCase):
|
||||
runner=runner.return_value,
|
||||
labels={'bink': 'boop'},
|
||||
log=mock.ANY,
|
||||
cont_log_path=None
|
||||
cont_log_path=None,
|
||||
healthcheck_disabled=False
|
||||
)
|
||||
builder.return_value.apply.assert_called_once_with()
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
When deploying with Podman, we can disable the container healthchecks by
|
||||
using paunch apply --healtcheck-disabled.
|
Loading…
Reference in New Issue
Block a user