Enable docker-puppet.py for a single config_volume

If docker-puppet.py fails on any config_volume, it can be difficult to
reproduce the failure given all the other entries in docker-puppet.json.
Often to reproduce a single failure, one has to modify the json file,
and remove all other entries, save the result to a new file, then pass
that new file as $CONFIG.

This commit adds the ability to specify $CONFIG_VOLUME, which will cause
docker-puppet.py to only run the configuration for the specified entry
in docker-puppet.json whose config_volume value matches the user
specified value.

Change-Id: I2889647a27a8b891696a6a3e7f78b59a015c2c79
Closes-Bug: #1737043
This commit is contained in:
James Slagle 2017-12-07 17:20:15 -05:00
parent 2e6ea5f5dc
commit c4e6a70864
2 changed files with 18 additions and 2 deletions

View File

@ -131,6 +131,8 @@ process_count = int(os.environ.get('PROCESS_COUNT',
log = get_logger()
log.info('Running docker-puppet')
config_file = os.environ.get('CONFIG', '/var/lib/docker-puppet/docker-puppet.json')
# If specified, only this config_volume will be used
config_volume_only = os.environ.get('CONFIG_VOLUME', None)
log.debug('CONFIG: %s' % config_file)
with open(config_file) as f:
json_data = json.load(f)
@ -187,8 +189,12 @@ for service in (json_data or []):
log.warn("Config containers do not match even though"
" shared volumes are the same!")
else:
log.debug("Adding new service")
configs[config_volume] = service
if not config_volume_only or (config_volume_only == config_volume):
log.debug("Adding new service")
configs[config_volume] = service
else:
log.debug("Ignoring %s due to $CONFIG_VOLUME=%s" %
(config_volume, config_volume_only))
log.info('Service compilation completed.')

View File

@ -0,0 +1,10 @@
---
fixes:
- If docker-puppet.py fails on any config_volume, it can be difficult to
reproduce the failure given all the other entries in docker-puppet.json.
Often to reproduce a single failure, one has to modify the json file, and
remove all other entries, save the result to a new file, then pass that new
file as $CONFIG. The ability to specify $CONFIG_VOLUME, which will cause
docker-puppet.py to only run the configuration for the specified entry in
docker-puppet.json whose config_volume value matches the user specified
value has been added.