From c4e6a708645b5b2b1220222a17aa8c8e69a15ca7 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Thu, 7 Dec 2017 17:20:15 -0500 Subject: [PATCH] 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 --- docker/docker-puppet.py | 10 ++++++++-- .../docker-puppet-config-volume-5ad50b90dc24672b.yaml | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/docker-puppet-config-volume-5ad50b90dc24672b.yaml diff --git a/docker/docker-puppet.py b/docker/docker-puppet.py index 18637f0a29..01bcee5e6c 100755 --- a/docker/docker-puppet.py +++ b/docker/docker-puppet.py @@ -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.') diff --git a/releasenotes/notes/docker-puppet-config-volume-5ad50b90dc24672b.yaml b/releasenotes/notes/docker-puppet-config-volume-5ad50b90dc24672b.yaml new file mode 100644 index 0000000000..58038326cc --- /dev/null +++ b/releasenotes/notes/docker-puppet-config-volume-5ad50b90dc24672b.yaml @@ -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.