From e42198368f9700f88f038c3a39fb042a431e742e Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Wed, 6 Jun 2018 10:15:08 +0200 Subject: [PATCH] Print a more informative error message on misconfigured volumes When making a mistake in the volumes configuration the error message thrown to the operator is something like the following: Traceback (most recent call last): File \"/var/lib/docker-puppet/docker-puppet.py\", line 394, in config_volumes = match_config_volumes(config_volume_prefix, v) File \"/var/lib/docker-puppet/docker-puppet.py\", line 89, in match_config_volumes volumes = config.get('volumes', []) AttributeError: 'list' object has no attribute 'get' Let's at least log *which* container had the failure. Change-Id: I37af67a52f12d8a5d643b03c6796a07b23d47ab5 --- docker/docker-puppet.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/docker-puppet.py b/docker/docker-puppet.py index 8b216004f7..6c62ba1c10 100755 --- a/docker/docker-puppet.py +++ b/docker/docker-puppet.py @@ -96,7 +96,11 @@ def pull_image(name): def match_config_volumes(prefix, config): # Match the mounted config volumes - we can't just use the # key as e.g "novacomute" consumes config-data/nova - volumes = config.get('volumes', []) + try: + volumes = config.get('volumes', []) + except AttributeError: + log.error('Error fetching volumes. Prefix: %s - Config: %s' % (prefix, config)) + raise return sorted([os.path.dirname(v.split(":")[0]) for v in volumes if v.startswith(prefix)])