From a854080cb5eed8701ce0f5bf6399dd7e37d4714b Mon Sep 17 00:00:00 2001 From: Damien Ciabrini Date: Mon, 20 Jan 2020 19:47:07 +0100 Subject: [PATCH] Fix generation of TRIPLEO_CONFIG_HASH for services A container gets a config hash if one of its bind mount references /var/lib/config-data/(puppet-generated)?/service. That hash is created/managed by container-puppet.py and stored in /var/lib/config-data/(puppet-generated)?/service.md5sum Currently, the parsing of bind-mount is broken so container-puppet.py never associates or regenerates config hashes for containers. Fix the parsing to make sure that any bind-mounts starting with /var/lib/config-data always resolve to the right md5sum file. Change-Id: I7ad50d62e6177f109f513c4c11f611be60e570f2 Closes-Bug: #1860364 (cherry picked from commit a5ffef4a40dbfb48926dfd6b0057547343b9a082) --- common/container-puppet.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/common/container-puppet.py b/common/container-puppet.py index 02c0dcfc72..c52e5f1bf7 100755 --- a/common/container-puppet.py +++ b/common/container-puppet.py @@ -140,6 +140,21 @@ def pull_image(name): log.debug(cmd_stderr) +def get_config_base(prefix, volume): + # crawl the volume's path upwards until we find the + # volume's base, where the hashed config file resides + path = volume + base = prefix.rstrip(os.path.sep) + base_generated = os.path.join(base, 'puppet-generated') + while path.startswith(prefix): + dirname = os.path.dirname(path) + if dirname == base or dirname == base_generated: + return path + else: + path = dirname + raise ValueError("Could not find config's base for '%s'" % volume) + + 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 @@ -148,8 +163,8 @@ def match_config_volumes(prefix, config): 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)]) + return sorted([get_config_base(prefix, v.split(":")[0]) + for v in volumes if v.startswith(prefix)]) def get_config_hash(config_volume):