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(
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)",
)