Fix sysinv-helm command.

Running the sysinv-helm command to create fluxcd app
overrides fails with a stack trace printed to terminal.

This fix pre-populates the apps_metadata_dict variable with
an empty dictionary in the event that its empty, which it would
be the first time when this command is run.

Test Plan:
PASS: Verify command 1 below produces {} in the output yaml.
PASS: Verify command 2 below produces fully populated output
      accross several yaml files.
PASS: Verify sysinv conductor starts up correctly with these
      changes in place.

Command 1:
system application-upload \
  /usr/local/share/applications/helm/metrics-server-1.1-44.tgz
sudo sysinv-helm create-fluxcd-app-overrides \
  /home/sysadmin metrics-server metrics-server

Command 2:
sudo sysinv-helm create-fluxcd-app-overrides \
  /home/sysadmin platform-integ-apps kube-system

Closes-Bug: 2055463

Change-Id: I3251776653bcfb1cf11f3dfec388953d476b8465
Signed-off-by: Joshua Reed <joshua.reed@windriver.com>
This commit is contained in:
Joshua Reed 2024-02-29 13:23:54 -07:00
parent b4a2053ea6
commit b2e75b771f
1 changed files with 9 additions and 0 deletions

View File

@ -2355,6 +2355,15 @@ class AppOperator(object):
then overwrite needs to be enabled to do the replacement
"""
# sysinv-helm command execution produces an empty cache. If empty, prime the
# cache with expected keys.
if not bool(apps_metadata_dict):
for k in [constants.APP_METADATA_APPS,
constants.APP_METADATA_PLATFORM_MANAGED_APP,
constants.APP_METADATA_DESIRED_STATES]:
apps_metadata_dict[k] = {}
if not overwrite and \
app_name in apps_metadata_dict[constants.APP_METADATA_APPS]:
LOG.info("Updating metadata for app {} skipped because metadata "