From dfabb0669f80ecbdaa23bbf4fe98ff23f587d711 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Thu, 31 Oct 2019 12:54:59 -0600 Subject: [PATCH] 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 96d39dc106ceacb52977d751dc1ef7dc70490070) --- tripleoclient/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index b7d1be54f..e2f889df3 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -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]",