Ensure unique containers names in docker-puppet

Use paunch as a library to not duplicate code around.

Related-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 6739889ae2
commit 5ccbdda93e
3 changed files with 10 additions and 3 deletions

View File

@ -28,7 +28,10 @@ import tempfile
import time
import multiprocessing
from paunch import runner as containers_runner
logger = None
RUNNER = containers_runner.DockerRunner('docker-puppet')
def get_logger():
@ -309,12 +312,14 @@ def mp_puppet_config(*args):
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(),
@ -377,7 +382,7 @@ def mp_puppet_config(*args):
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

@ -82,6 +82,7 @@ paramiko==2.0.0
passlib==1.7.0
Paste==2.0.2
PasteDeploy==1.5.0
paunch==3.2.0
pbr==2.0.0
pecan==1.0.0
pika-pool==0.1.3

View File

@ -6,3 +6,4 @@ PyYAML>=3.12 # MIT
Jinja2>=2.10 # BSD License (3 clause)
six>=1.10.0 # MIT
tripleo-common>=7.1.0 # Apache-2.0
paunch>=3.2.0 # Apache-2.0