aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorMark Goddard <mark@stackhpc.com>2020-08-06 10:50:25 +0100
committerRadosław Piliszek <radoslaw.piliszek@gmail.com>2020-08-28 15:01:25 +0000
commitc5320eb22386c34d83435fa0b9aa03b178996b52 (patch)
tree7988cda9ff2df403adf84b7c327ed2fe04224619 /docker
parentb4dde581c528c2072e408768601b75a97551e5a8 (diff)
downloadkolla-c5320eb22386c34d83435fa0b9aa03b178996b52.tar.gz
kolla-c5320eb22386c34d83435fa0b9aa03b178996b52.zip
Fix kolla_set_configs --check with a directory
There are several issues with kolla_set_configs --check: 1. We calculate the destination path incorrectly when comparing a file in a directory, due to passing arguments to os.path.relpath in the wrong order 2. For directories that have not changed, we also attempt to compare them as files, which fails when they are open()ed. 3. If the config JSON does not have a config_files key, it fails with a KeyError. The first two issues affect the fluentd container, which specifies directories as the source, without using a glob. The third affects OVN containers. This patch fixes these issues. Closes-Bug: #1890567 Change-Id: I8921befe51da4282121443849177a7ca5ebe8822
Diffstat (limited to 'docker')
-rw-r--r--docker/base/set_configs.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py
index 5f030866f..572e4a001 100644
--- a/docker/base/set_configs.py
+++ b/docker/base/set_configs.py
@@ -204,8 +204,8 @@ class ConfigFile(object):
return False
for file_ in files:
full_path = os.path.join(root, file_)
- dest_full_path = os.path.join(dest, os.path.relpath(source,
- full_path))
+ dest_full_path = os.path.join(dest, os.path.relpath(full_path,
+ source))
if not self._cmp_file(full_path, dest_full_path):
return False
return True
@@ -225,8 +225,9 @@ class ConfigFile(object):
# otherwise means copy the source to dest
if dest.endswith(os.sep):
dest = os.path.join(dest, os.path.basename(source))
- if os.path.isdir(source) and not self._cmp_dir(source, dest):
- bad_state_files.append(source)
+ if os.path.isdir(source):
+ if not self._cmp_dir(source, dest):
+ bad_state_files.append(source)
elif not self._cmp_file(source, dest):
bad_state_files.append(source)
if len(bad_state_files) != 0:
@@ -404,7 +405,7 @@ def execute_config_strategy(config):
def execute_config_check(config):
- for data in config['config_files']:
+ for data in config.get('config_files', []):
config_file = ConfigFile(**data)
config_file.check()