async def check_workflow_and_update_db(self, op_id, workflow_name, db_content):
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"Workflow Status: {} Workflow Message: {}".format(
for checking in checkings_list:
if checking["enable"]:
status, message = await self.odu.readiness_loop(
+ op_id=op_id,
item=checking["item"],
name=checking["name"],
namespace=checking["namespace"],
self.logger.info("workflow_name is: {}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"workflow_status is: {} and workflow_msg is: {}".format(
self.logger.info("workflow_name is: {}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"workflow_status is: {} and workflow_msg is: {}".format(
self.logger.info("workflow_name is: {}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"workflow_status is: {} and workflow_msg is: {}".format(
self.logger.info("workflow_name is: {}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"workflow_status is: {} and workflow_msg is: {}".format(
self.logger.info("workflow_name is: {}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"workflow_status is: {} and workflow_msg is: {}".format(
self.logger.info("workflow_name is: {}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"workflow_status is: {} and workflow_msg is: {}".format(
return
self.logger.info("workflow_name is: {}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"Workflow Status: {} Workflow Message: {}".format(
)
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"update_cloud_credentials", op_id, op_params, db_content
)
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"Workflow Status: {} Workflow Msg: {}".format(workflow_status, workflow_msg)
"delete_cloud_credentials", op_id, op_params, db_content
)
workflow_status, workflow_msg = await self.odu.check_workflow_status(
- workflow_name
+ op_id, workflow_name
)
self.logger.info(
"Workflow Status: {} Workflow Msg: {}".format(workflow_status, workflow_msg)
from jsonpath_ng.ext import parse
-async def check_workflow_status(self, workflow_name):
- self.logger.info(f"check_workflow_status Enter: {workflow_name}")
+async def check_workflow_status(self, op_id, workflow_name):
+ self.logger.info(f"Op {op_id}, check_workflow_status Enter: {workflow_name}")
if not workflow_name:
return False, "Workflow was not launched"
try:
# First check if the workflow ends successfully
completed, message = await self.readiness_loop(
+ op_id,
item="workflow",
name=workflow_name,
namespace="osm-workflows",
if completed:
# Then check if the workflow has a failed task
return await self.readiness_loop(
+ op_id,
item="workflow",
name=workflow_name,
namespace="osm-workflows",
async def readiness_loop(
- self, item, name, namespace, condition, deleted, timeout, kubectl=None
+ self, op_id, item, name, namespace, condition, deleted, timeout, kubectl=None
):
if kubectl is None:
kubectl = self._kubectl
- self.logger.info("readiness_loop Enter")
+ self.logger.info("Op {op_id} readiness_loop Enter")
self.logger.info(
- f"{item} {name}. Namespace: '{namespace}'. Condition: {condition}. Deleted: {deleted}. Timeout: {timeout}"
+ f"Op {op_id}. {item} {name}. Namespace: '{namespace}'. Condition: {condition}. Deleted: {deleted}. Timeout: {timeout}"
)
item_api_map = {
"workflow": {
api_version = item_api_map[item]["api_version"]
while counter <= max_iterations:
+ iteration_prefix = f"Op {op_id}. Iteration {counter}/{max_iterations}"
try:
- self.logger.info(f"Iteration {counter}/{max_iterations}")
+ self.logger.info(f"Op {op_id}. Iteration {counter}/{max_iterations}")
generic_object = await kubectl.get_generic_object(
api_group=api_group,
api_plural=api_plural,
if deleted:
if generic_object:
self.logger.info(
- f"Iteration {counter}/{max_iterations}: Found {api_plural}. Name: {name}. Namespace: '{namespace}'. API: {api_group}/{api_version}"
+ f"{iteration_prefix}. Found {api_plural}. Name: {name}. Namespace: '{namespace}'. API: {api_group}/{api_version}"
)
else:
self.logger.info(
- f"{item} {name} deleted after {counter} iterations (aprox {counter*retry_time} seconds)"
+ f"{iteration_prefix}. {item} {name} deleted after {counter} iterations (aprox {counter*retry_time} seconds)"
)
return True, "COMPLETED"
else:
# self.logger.debug(f"{yaml.safe_dump(generic_object)}")
conditions = generic_object.get("status", {}).get("conditions", [])
self.logger.info(
- f"Iteration {counter}/{max_iterations}. Object found: {item} status conditions: {conditions}"
+ f"{iteration_prefix}. Object found: {item} status conditions: {conditions}"
)
jsonpath_expr = parse(condition["jsonpath_filter"])
match = jsonpath_expr.find(generic_object)
)
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)"
+ f"{iteration_prefix}. {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}"
+ f"{iteration_prefix}. {item} {name} did not meet the condition {condition} with value {value}"
)
else:
self.logger.info(
- f"Iteration {counter}/{max_iterations}. No match for filter {condition.get('jsonpath_filter', '-')} in {item} {name}"
+ f"{iteration_prefix}. No match for filter {condition.get('jsonpath_filter', '-')} in {item} {name}"
)
else:
self.logger.info(
- f"Iteration {counter}/{max_iterations}: Could not find {api_plural}. Name: {name}. Namespace: '{namespace}'. API: {api_group}/{api_version}"
+ f"{iteration_prefix}. Could not find {api_plural}. Name: {name}. Namespace: '{namespace}'. API: {api_group}/{api_version}"
)
except Exception as e:
self.logger.error(f"Exception: {e}")
counter += 1
return (
False,
- f"{item} {name} was not ready after {max_iterations} iterations (aprox {timeout} seconds)",
+ f"Op {op_id}. {item} {name} was not ready after {max_iterations} iterations (aprox {timeout} seconds)",
)