)
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ # Clean items used in the workflow or in the cluster, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "delete_cluster", op_id, op_params, db_cluster_copy
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
+
if workflow_status:
resource_status, resource_msg = await self.check_resource_status(
"delete_cluster", op_id, op_params, db_cluster_copy
)
)
if workflow_status:
- db_cluster["state"] = "DELETED"
db_cluster["resourceState"] = "IN_PROGRESS.GIT_SYNCED"
else:
db_cluster["state"] = "FAILED_DELETION"
else:
db_cluster["resourceState"] = "ERROR"
- db_cluster["operatingState"] = "IDLE"
db_cluster = self.update_operation_history(
db_cluster, op_id, workflow_status, resource_status
)
- db_cluster["current_operation"] = None
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
- # To delete it from DB
- if db_cluster["state"] == "DELETED":
- self.db.del_one("clusters", {"_id": db_cluster["_id"]})
-
- # To delete it from k8scluster collection
- self.db.del_one("k8sclusters", {"name": db_cluster["name"]})
-
- return
+ return await self.delete(params, order_id)
async def get_creds(self, params, order_id):
self.logger.info("Cluster get creds Enter")
self.logger.info("workflow function : {}".format(workflow_function))
return await workflow_function(op_id, op_params, content)
+ async def dummy_clean_items(self, key, op_id, op_params, content):
+ self.logger.info(
+ f"Dummy clean items. Key: {key}. Operation: {op_id}. Params: {op_params}. Content: {content}"
+ )
+ return True, "OK"
+
async def clean_items_workflow(self, key, op_id, op_params, content):
self.logger.info(
f"Cleaning items created during workflow launch. Key: {key}. Operation: {op_id}. Params: {op_params}. Content: {content}"
)
- clean_items_function = self._workflows[key]["clean_function"]
+ clean_items_function = self._workflows[key].get(
+ "clean_function", self.dummy_clean_items
+ )
self.logger.info("clean items function : {}".format(clean_items_function))
return await clean_items_function(op_id, op_params, content)