From ed3b5a81555c06630c4715e754f08701a4d0ea85 Mon Sep 17 00:00:00 2001 From: Shrikumar Sharma Date: Fri, 12 Nov 2021 12:06:00 -0500 Subject: [PATCH] Handle exceptions in sysinv due to missing service parameters When the ghcr docker service parameter is missing sysinv fails to download images and spams the logs with an exception. This exception occurs within another except block and hides the true error. This fix changes the variable used in an exception message when an image download from public/private registry fails. If the exception occurs, pub_img_tag is not assigned and the UnboundLocalError issue occurs due to the usage of pub_img_tag in the exception handler. This fix improves the original fix in https://opendev.org/starlingx/config/commit/88cacfc5d582a3bb7524a1a5599b289a52ab1f0d to fix this scenario. Test Plan: PASS: Verify that the exceptions do not occur when the patch for service parameters is not present Closes-Bug: 1951014 Change-Id: I77db038d2f33fd42b9b8963fc6b31ebb0c425f6c Change-Id: I720f63878f6672eccbe1a109f762966d73eef154 Signed-off-by: Shrikumar Sharma --- sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py b/sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py index b1f5851c58..185b858f99 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py @@ -3103,15 +3103,19 @@ class DockerHelper(object): LOG.info("Image %s is not available in local registry, " "download started from public/private registry" % img_tag) + pub_img_tag = img_tag.replace( constants.DOCKER_REGISTRY_SERVER + "/", "") + target_img_tag, registry_auth = \ self._get_img_tag_with_registry(pub_img_tag, registries_info) + client.pull(target_img_tag, auth_config=registry_auth) + except Exception as e: rc = False LOG.error("Image %s download failed from public/private" - "registry: %s" % (pub_img_tag, e)) + "registry: %s" % (img_tag, e)) return img_tag, rc try: