Take all mounted config_volumes into account
We need to account for all the mounted config volumes when generating the TRIPLEO_CONFIG_HASH in order for paunch to know to restart the container when any one of the config_volume gets updated. Change-Id: I473a71f49bd446694da48bb5b7b0a49126df7845 Closes-Bug: #1721306
This commit is contained in:
parent
3a932b0569
commit
8aef24de81
@ -83,16 +83,12 @@ def pull_image(name):
|
||||
log.debug(cmd_stderr)
|
||||
|
||||
|
||||
def match_config_volume(prefix, config):
|
||||
# Match the mounted config volume - we can't just use the
|
||||
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', [])
|
||||
config_volume = None
|
||||
for v in volumes:
|
||||
if v.startswith(prefix):
|
||||
config_volume = os.path.dirname(v.split(":")[0])
|
||||
break
|
||||
return config_volume
|
||||
return sorted([os.path.dirname(v.split(":")[0]) for v in volumes if
|
||||
v.startswith(prefix)])
|
||||
|
||||
|
||||
def get_config_hash(config_volume):
|
||||
@ -371,14 +367,15 @@ for infile in infiles:
|
||||
infile_data = json.load(f)
|
||||
|
||||
for k, v in infile_data.iteritems():
|
||||
config_volume = match_config_volume(config_volume_prefix, v)
|
||||
if config_volume:
|
||||
config_hash = get_config_hash(config_volume)
|
||||
if config_hash:
|
||||
env = v.get('environment', [])
|
||||
env.append("TRIPLEO_CONFIG_HASH=%s" % config_hash)
|
||||
log.debug("Updating config hash for %s, config_volume=%s hash=%s" % (k, config_volume, config_hash))
|
||||
infile_data[k]['environment'] = env
|
||||
config_volumes = match_config_volumes(config_volume_prefix, v)
|
||||
config_hashes = [get_config_hash(volume_path) for volume_path in config_volumes]
|
||||
config_hashes = filter(None, config_hashes)
|
||||
config_hash = '-'.join(config_hashes)
|
||||
if config_hash:
|
||||
env = v.get('environment', [])
|
||||
env.append("TRIPLEO_CONFIG_HASH=%s" % config_hash)
|
||||
log.debug("Updating config hash for %s, config_volume=%s hash=%s" % (k, config_volume, config_hash))
|
||||
infile_data[k]['environment'] = env
|
||||
|
||||
outfile = os.path.join(os.path.dirname(infile), "hashed-" + os.path.basename(infile))
|
||||
with open(outfile, 'w') as out_f:
|
||||
|
Loading…
Reference in New Issue
Block a user