From dd799ac3d8d3159ae67346905f73c5f95e29e9e4 Mon Sep 17 00:00:00 2001 From: quilesj Date: Thu, 23 Jan 2020 16:31:11 +0000 Subject: [PATCH] Fix bug 996. Error when cluster is not ready Change-Id: Ic399f8ffb4283ab0ce89361fd9c74b20bde223ec Signed-off-by: quilesj --- osm_lcm/ns.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 07faafe..9d8812a 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -2080,32 +2080,33 @@ class NsLcm(LcmBase): pending_tasks[task] = "_admin.deployed.K8s.{}.".format(index) index += 1 - if not pending_tasks: - return - self.logger.debug(logging_text + 'Waiting for terminate pending tasks...') - pending_list = list(pending_tasks.keys()) - while pending_list: - done_list, pending_list = await asyncio.wait(pending_list, timeout=30*60, - return_when=asyncio.FIRST_COMPLETED) - if not done_list: # timeout - for task in pending_list: - db_nsr_update[pending_tasks(task) + "detailed-status"] = "Timeout" - deployed_ok = False - break - for task in done_list: - exc = task.exception() - if exc: - db_nsr_update[pending_tasks[task] + "detailed-status"] = "{}".format(exc) - deployed_ok = False - else: - db_nsr_update[pending_tasks[task] + "kdu-instance"] = task.result() + + if pending_tasks: + self.logger.debug(logging_text + 'Waiting for terminate pending tasks...') + pending_list = list(pending_tasks.keys()) + while pending_list: + done_list, pending_list = await asyncio.wait(pending_list, timeout=30*60, + return_when=asyncio.FIRST_COMPLETED) + if not done_list: # timeout + for task in pending_list: + db_nsr_update[pending_tasks(task) + "detailed-status"] = "Timeout" + deployed_ok = False + break + for task in done_list: + exc = task.exception() + if exc: + db_nsr_update[pending_tasks[task] + "detailed-status"] = "{}".format(exc) + deployed_ok = False + else: + db_nsr_update[pending_tasks[task] + "kdu-instance"] = task.result() if not deployed_ok: raise LcmException('Cannot deploy KDUs') except Exception as e: - self.logger.critical(logging_text + "Exit Exception {} while '{}': {}".format(type(e).__name__, step, e)) - raise LcmException("{} Exit Exception {} while '{}': {}".format(logging_text, type(e).__name__, step, e)) + msg = "{} Exit Exception {} while '{}': {}".format(logging_text, type(e).__name__, step, e) + self.logger.error(msg) + raise LcmException(msg) finally: if db_nsr_update: self.update_db_2("nsrs", nsr_id, db_nsr_update) -- 2.17.1