Clean-up of resources created in ODU workflows
Change-Id: Ib2051d5844841d6469a4dc3e854ff2ef88a36a87
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/osm_lcm/k8s.py b/osm_lcm/k8s.py
index c48228e..a02e165 100644
--- a/osm_lcm/k8s.py
+++ b/osm_lcm/k8s.py
@@ -69,6 +69,14 @@
db_cluster = self.update_operation_history(db_cluster, workflow_status, None)
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ # Clean items used in the workflow, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "create_cluster", op_id, op_params, content
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
+
if workflow_status:
resource_status, resource_msg = await self.odu.check_resource_status(
"create_cluster", op_id, op_params, content
@@ -487,6 +495,13 @@
# self.db.set_one(self.db_collection, {"_id": _id}, db_cluster)
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ # Clean items used in the workflow, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "update_cluster", op_id, op_params, content
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
if workflow_status:
resource_status, resource_msg = await self.odu.check_resource_status(
"update_cluster", op_id, op_params, content
@@ -549,6 +564,14 @@
"Workflow Status: {} Workflow Msg: {}".format(workflow_status, workflow_msg)
)
+ # Clean items used in the workflow, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "create_cloud_credentials", op_id, op_params, content
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
+
if workflow_status:
resource_status, resource_msg = await self.odu.check_resource_status(
"create_cloud_credentials", op_id, op_params, content
@@ -571,6 +594,14 @@
"Workflow Status: {} Workflow Msg: {}".format(workflow_status, workflow_msg)
)
+ # Clean items used in the workflow, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "update_cloud_credentials", op_id, op_params, content
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
+
if workflow_status:
resource_status, resource_msg = await self.odu.check_resource_status(
"update_cloud_credentials", op_id, op_params, content