Ensure unique containers names in docker-puppet

Use paunch as a library to not duplicate code around.

Closes-Bug: #1799573

Change-Id: I4386b155a4bdba430dc350914db7a6b6fdf92ac0
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
(cherry picked from commit 6bec6c885f)
This commit is contained in:
Bogdan Dobrelya 2018-10-25 14:00:57 +02:00
parent 8910bc71a3
commit b6cfecbe32
2 changed files with 10 additions and 3 deletions

View File

@ -28,7 +28,11 @@ import tempfile
import time
import multiprocessing
from paunch import runner as containers_runner
logger = None
RUNNER = containers_runner.DockerRunner(
'docker-puppet')
def get_logger():
@ -286,12 +290,14 @@ def mp_puppet_config((config_volume, puppet_tags, manifest, config_image, volume
man_file.write('include ::tripleo::packages\n')
man_file.write(manifest)
rm_container('docker-puppet-%s' % config_volume)
uname = RUNNER.unique_container_name('docker-puppet-%s' %
config_volume)
rm_container(uname)
pull_image(config_image)
dcmd = ['/usr/bin/docker', 'run',
'--user', 'root',
'--name', 'docker-puppet-%s' % config_volume,
'--name', uname,
'--env', 'PUPPET_TAGS=%s' % puppet_tags,
'--env', 'NAME=%s' % config_volume,
'--env', 'HOSTNAME=%s' % short_hostname(),
@ -349,7 +355,7 @@ def mp_puppet_config((config_volume, puppet_tags, manifest, config_image, volume
if cmd_stderr:
log.debug(cmd_stderr)
# only delete successful runs, for debugging
rm_container('docker-puppet-%s' % config_volume)
rm_container(uname)
log.info('Finished processing puppet configs for %s' % (config_volume))
return subproc.returncode

View File

@ -5,3 +5,4 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
Jinja2!=2.9.0,!=2.9.1,!=2.9.2,!=2.9.3,!=2.9.4,>=2.8 # BSD License (3 clause)
six>=1.10.0 # MIT
tripleo-common>=7.1.0 # Apache-2.0
paunch>=1.0.0 # Apache-2.0