diff --git a/osm_lcm/k8s.py b/osm_lcm/k8s.py index dda07fbb51c92bccf83676f7692aed6b3578956e..fd3667dabfb5cc565ddbe6a46cb6ad9ee7391d42 100644 --- a/osm_lcm/k8s.py +++ b/osm_lcm/k8s.py @@ -2054,7 +2054,7 @@ class KsuLcm(GitOpsLcm): for db_cluster in dbcluster_list: try: self.logger.info( - f"Checking status of KSU in cluster {db_cluster['name']}." + f"Checking status of KSU {db_ksu['name']} in cluster {db_cluster['name']}." ) cluster_kubectl = self.cluster_kubectl(db_cluster) checkings_list = [ diff --git a/osm_lcm/odu_libs/workflows.py b/osm_lcm/odu_libs/workflows.py index cf09e8fa5b44dcd698ed3fbddb9ee8544deaf71c..1b5d5cc64be73b38b28315f6a3f51823c9b914fe 100644 --- a/osm_lcm/odu_libs/workflows.py +++ b/osm_lcm/odu_libs/workflows.py @@ -107,7 +107,7 @@ async def readiness_loop( if deleted: if generic_object: self.logger.info( - f"Found {api_plural}. Name: {name}. Namespace: '{namespace}'. API: {api_group}/{api_version}" + f"Iteration {counter}/{max_iterations}: Found {api_plural}. Name: {name}. Namespace: '{namespace}'. API: {api_group}/{api_version}" ) else: self.logger.info( @@ -118,29 +118,41 @@ async def readiness_loop( if not condition: return True, "Nothing to check" if generic_object: + # If there is object, conditions must be checked # self.logger.debug(f"{yaml.safe_dump(generic_object)}") conditions = generic_object.get("status", {}).get("conditions", []) - self.logger.info(f"{item} status conditions: {conditions}") - else: self.logger.info( - f"Could not find {api_plural}. Name: {name}. Namespace: '{namespace}'. API: {api_group}/{api_version}" + f"Iteration {counter}/{max_iterations}. Object found: {item} status conditions: {conditions}" ) - conditions = [] - jsonpath_expr = parse(condition["jsonpath_filter"]) - match = jsonpath_expr.find(generic_object) - if match: - value = match[0].value - condition_function = condition.get("function", lambda x, y: x == y) - if condition_function(condition["value"], value): + jsonpath_expr = parse(condition["jsonpath_filter"]) + match = jsonpath_expr.find(generic_object) + if match: + value = match[0].value + condition_function = condition.get( + "function", lambda x, y: x == y + ) + if condition_function(condition["value"], value): + self.logger.info( + f"{item} {name} met the condition {condition} with {value} in {counter} iterations (aprox {counter*retry_time} seconds)" + ) + return True, "COMPLETED" + else: + self.logger.info( + f"Iteration {counter}/{max_iterations}: {item} {name} did not meet the condition {condition} with value {value}" + ) + else: self.logger.info( - f"{item} {name} met the condition {condition} in {counter} iterations (aprox {counter*retry_time} seconds)" + f"Iteration {counter}/{max_iterations}. No match for filter {condition.get('jsonpath_filter', '-')} in {item} {name}" ) - return True, "COMPLETED" + else: + self.logger.info( + f"Iteration {counter}/{max_iterations}: Could not find {api_plural}. Name: {name}. Namespace: '{namespace}'. API: {api_group}/{api_version}" + ) except Exception as e: self.logger.error(f"Exception: {e}") await asyncio.sleep(retry_time) counter += 1 return ( False, - "{item} {name} was not ready after {max_iterations} iterations (aprox {timeout} seconds)", + f"{item} {name} was not ready after {max_iterations} iterations (aprox {timeout} seconds)", )