Quote the health check command argument during a debug with print-cmd.
This is one of the few arguments that sometimes requires the use of
spaces. `paunch debug --action print-cmd` will now display a command
to stdout that can be copied, pasted, and executed reliability.
Change-Id: I04d2f141370cd88787422d6adf4b22cc54ecf028
Resolves: rhbz#1694572
Signed-off-by: Luke Short <ekultails@gmail.com>
(cherry picked from commit a304153948
)
This commit is contained in:
parent
3a81ee15ad
commit
210c0d662e
|
@ -194,6 +194,18 @@ def debug(config_id, container_name, action, config, managed_by, labels=None,
|
|||
r.unique_container_name(container_name)
|
||||
]
|
||||
builder.container_run_args(cmd, container_name)
|
||||
|
||||
if '--health-cmd' in cmd:
|
||||
health_check_arg_index = cmd.index('--health-cmd') + 1
|
||||
|
||||
# The argument given needs to be quoted to work properly with a
|
||||
# copy and paste of the full command.
|
||||
try:
|
||||
cmd[health_check_arg_index] = (
|
||||
'"%s"' % cmd[health_check_arg_index])
|
||||
except IndexError:
|
||||
log.warning("No argument provided to --health-cmd.")
|
||||
|
||||
print(' '.join(cmd))
|
||||
elif action == 'run':
|
||||
cmd = [
|
||||
|
|
|
@ -44,7 +44,8 @@ class ComposeV1Builder(base.BaseBuilder):
|
|||
if 'healthcheck' in cconfig:
|
||||
hconfig = cconfig['healthcheck']
|
||||
if 'test' in hconfig:
|
||||
cmd.append('--health-cmd=%s' % hconfig['test'])
|
||||
cmd.append('--health-cmd')
|
||||
cmd.append(str(hconfig['test']))
|
||||
if 'interval' in hconfig:
|
||||
cmd.append('--health-interval=%s' % hconfig['interval'])
|
||||
if 'timeout' in hconfig:
|
||||
|
|
|
@ -53,7 +53,8 @@ class TestComposeV1Builder(tbb.TestBaseBuilder):
|
|||
['docker', 'run', '--name', 'one',
|
||||
'--detach=true', '--env-file=/tmp/foo.env',
|
||||
'--net=host', '--ipc=host', '--pid=container:bar',
|
||||
'--uts=host', '--health-cmd=/bin/true', '--health-interval=30s',
|
||||
'--uts=host', '--health-cmd', '/bin/true',
|
||||
'--health-interval=30s',
|
||||
'--health-timeout=10s', '--health-retries=3',
|
||||
'--privileged=true', '--restart=always', '--user=bar',
|
||||
'--log-opt=tag={{.ImageName}}/{{.Name}}/{{.ID}}',
|
||||
|
|
Loading…
Reference in New Issue