Remove old per step startup configs

There may be cases where certain steps may not exist after
removal of services during update/upgrade. As we recreate
the startup configs per step every time, let's clean all.
If we need to archive old configs we can backup docker_config.yaml
which can be done in a separate THT patch.

Change-Id: I200865bfd03aa63a9fe07b517bf60151e495455f
Closes-bug: #1959662
(cherry picked from commit 36b2175afb)
This commit is contained in:
rabi 2022-02-08 08:38:24 +05:30 committed by Rabi Mishra
parent d51ec13bcf
commit fa2967f710
1 changed files with 4 additions and 3 deletions

View File

@ -93,8 +93,6 @@ class ContainerStartupManager:
# Generate the container configs per step
for step, step_config in self.config_data.items():
step_dir = os.path.join(self.config_base_dir, step)
# Note: it'll cleanup old configs before creating new ones.
# TODO(emilien) add idempotency so we only remove the needed files
self._recreate_dir(step_dir)
for container, container_config in step_config.items():
container_config_path = os.path.join(self.config_base_dir,
@ -108,7 +106,6 @@ class ContainerStartupManager:
:param path: string
"""
shutil.rmtree(path, ignore_errors=True)
os.makedirs(path)
def _create_config(self, path, config):
@ -131,6 +128,10 @@ class ContainerStartupManager:
for config in old_configs:
os.remove(config)
step_dirs = glob.glob(self.config_base_dir + '/step_*')
for step_dir in step_dirs:
shutil.rmtree(step_dir, ignore_errors=True)
def main():
module = AnsibleModule(