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 a5ffef4a40)
This commit is contained in:
Damien Ciabrini 2020-01-20 19:47:07 +01:00 committed by Emilien Macchi
parent 7343c374a6
commit f98605c1df
1 changed files with 17 additions and 2 deletions

View File

@ -139,6 +139,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
@ -147,8 +162,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):