Ensure unique containers names in docker-puppet
Use paunch as a library to not duplicate code around. We'll need to add the logger once we have paunch 4.0.1 and rpm promoted with the recent logging fixes. Closes-Bug: #1799573 Change-Id: I4386b155a4bdba430dc350914db7a6b6fdf92ac0 Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
parent
03ca0e5d31
commit
6bec6c885f
@ -28,6 +28,8 @@ import tempfile
|
|||||||
import time
|
import time
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
|
from paunch import runner as containers_runner
|
||||||
|
|
||||||
logger = None
|
logger = None
|
||||||
sh_script = '/var/lib/docker-puppet/docker-puppet.sh'
|
sh_script = '/var/lib/docker-puppet/docker-puppet.sh'
|
||||||
container_cli = os.environ.get('CONTAINER_CLI', 'docker')
|
container_cli = os.environ.get('CONTAINER_CLI', 'docker')
|
||||||
@ -63,6 +65,9 @@ if not os.path.exists(config_volume_prefix):
|
|||||||
if container_cli == 'docker':
|
if container_cli == 'docker':
|
||||||
cli_dcmd = ['--volume', '/usr/share/openstack-puppet/modules/:/usr/share/openstack-puppet/modules/:ro,z']
|
cli_dcmd = ['--volume', '/usr/share/openstack-puppet/modules/:/usr/share/openstack-puppet/modules/:ro,z']
|
||||||
env = {}
|
env = {}
|
||||||
|
# FIXME: add log=log once we have paunch 4.0.1 in Pypi and promoted in RDO
|
||||||
|
RUNNER = containers_runner.DockerRunner(
|
||||||
|
'docker-puppet', cont_cmd='docker')
|
||||||
elif container_cli == 'podman':
|
elif container_cli == 'podman':
|
||||||
# podman doesn't allow relabeling content in /usr and
|
# podman doesn't allow relabeling content in /usr and
|
||||||
# doesn't support named volumes
|
# doesn't support named volumes
|
||||||
@ -70,6 +75,9 @@ elif container_cli == 'podman':
|
|||||||
'--volume', '/usr/share/openstack-puppet/modules/:/usr/share/openstack-puppet/modules/:ro']
|
'--volume', '/usr/share/openstack-puppet/modules/:/usr/share/openstack-puppet/modules/:ro']
|
||||||
# podman need to find dependent binaries that are in environment
|
# podman need to find dependent binaries that are in environment
|
||||||
env = {'PATH': os.environ['PATH']}
|
env = {'PATH': os.environ['PATH']}
|
||||||
|
# FIXME: add log=log once we have paunch 4.0.1 in Pypi and promoted in RDO
|
||||||
|
RUNNER = containers_runner.PodmanRunner(
|
||||||
|
'docker-puppet', cont_cmd='podman')
|
||||||
else:
|
else:
|
||||||
log.error('Invalid container_cli: %s' % container_cli)
|
log.error('Invalid container_cli: %s' % container_cli)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -347,12 +355,14 @@ def mp_puppet_config(*args):
|
|||||||
man_file.write('include ::tripleo::packages\n')
|
man_file.write('include ::tripleo::packages\n')
|
||||||
man_file.write(manifest)
|
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)
|
pull_image(config_image)
|
||||||
|
|
||||||
common_dcmd = [cli_cmd, 'run',
|
common_dcmd = [cli_cmd, 'run',
|
||||||
'--user', 'root',
|
'--user', 'root',
|
||||||
'--name', 'docker-puppet-%s' % config_volume,
|
'--name', uname,
|
||||||
'--env', 'PUPPET_TAGS=%s' % puppet_tags,
|
'--env', 'PUPPET_TAGS=%s' % puppet_tags,
|
||||||
'--env', 'NAME=%s' % config_volume,
|
'--env', 'NAME=%s' % config_volume,
|
||||||
'--env', 'HOSTNAME=%s' % short_hostname(),
|
'--env', 'HOSTNAME=%s' % short_hostname(),
|
||||||
@ -419,7 +429,7 @@ def mp_puppet_config(*args):
|
|||||||
if cmd_stderr:
|
if cmd_stderr:
|
||||||
log.debug(cmd_stderr)
|
log.debug(cmd_stderr)
|
||||||
# only delete successful runs, for debugging
|
# 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))
|
log.info('Finished processing puppet configs for %s' % (config_volume))
|
||||||
return subproc.returncode
|
return subproc.returncode
|
||||||
|
@ -82,6 +82,7 @@ paramiko==2.0.0
|
|||||||
passlib==1.7.0
|
passlib==1.7.0
|
||||||
Paste==2.0.2
|
Paste==2.0.2
|
||||||
PasteDeploy==1.5.0
|
PasteDeploy==1.5.0
|
||||||
|
paunch==4.0.0
|
||||||
pbr==2.0.0
|
pbr==2.0.0
|
||||||
pecan==1.0.0
|
pecan==1.0.0
|
||||||
pika-pool==0.1.3
|
pika-pool==0.1.3
|
||||||
|
@ -6,3 +6,4 @@ PyYAML>=3.12 # MIT
|
|||||||
Jinja2>=2.10 # BSD License (3 clause)
|
Jinja2>=2.10 # BSD License (3 clause)
|
||||||
six>=1.10.0 # MIT
|
six>=1.10.0 # MIT
|
||||||
tripleo-common>=7.1.0 # Apache-2.0
|
tripleo-common>=7.1.0 # Apache-2.0
|
||||||
|
paunch>=4.0.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user