Improve handling of empty resource_registry

It's possible that content["resource_registry"] might
not exist or be iterable so wrap the reference to it
with a try/except for a KeyError or TypeError and continue
the deployment without the empty resource_registry instead
of failing.

Change-Id: Ic7d88382a0ff15c24800f12ddbf69f13d6804b28
Closes-Bug: #1833743
(cherry picked from commit 96d39dc106)
This commit is contained in:
Alex Schultz 2019-10-31 12:54:59 -06:00
parent 1696ed35d0
commit dfabb0669f
1 changed files with 4 additions and 3 deletions

View File

@ -1209,14 +1209,15 @@ def check_file_for_enabled_service(env_file):
content = yaml.load(open(env_file))
deprecated_services_enabled = []
for service in constants.DEPRECATED_SERVICES.keys():
if ("resource_registry" in content and
service in content["resource_registry"]):
try:
if content["resource_registry"][service] != "OS::Heat::None":
log.warning("service " + service + " is enabled in "
+ str(env_file) + ". " +
constants.DEPRECATED_SERVICES[service])
deprecated_services_enabled.append(service)
except (KeyError, TypeError):
# ignore if content["resource_registry"] is empty
pass
if deprecated_services_enabled:
confirm = prompt_user_for_confirmation(
message="Do you still wish to continue with deployment [y/N]",