Inspect exception during cluster deletion 84/14984/7
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 12 Feb 2025 15:45:40 +0000 (16:45 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 10 Mar 2025 14:39:30 +0000 (15:39 +0100)
Change-Id: If301ed2c1199450a62554f8f4411e14c41707b8f
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/k8s.py

index 104515b..20d47a5 100644 (file)
@@ -577,27 +577,34 @@ class ClusterLcm(GitOpsLcm):
     async def delete(self, params, order_id):
         self.logger.info("cluster delete Enter")
 
-        # To get the cluster and op ids
-        cluster_id = params["cluster_id"]
-        op_id = params["operation_id"]
+        try:
+            # To get the cluster and op ids
+            cluster_id = params["cluster_id"]
+            op_id = params["operation_id"]
 
-        # To initialize the operation states
-        self.initialize_operation(cluster_id, op_id)
+            # To initialize the operation states
+            self.initialize_operation(cluster_id, op_id)
 
-        # To get the cluster
-        db_cluster = self.db.get_one("clusters", {"_id": cluster_id})
+            # To get the cluster
+            db_cluster = self.db.get_one("clusters", {"_id": cluster_id})
 
-        # To get the operation params details
-        op_params = self.get_operation_params(db_cluster, op_id)
+            # To get the operation params details
+            op_params = self.get_operation_params(db_cluster, op_id)
 
-        # To copy the cluster content and decrypting fields to use in workflows
-        workflow_content = {
-            "cluster": self.decrypted_copy(db_cluster),
-        }
+            # To copy the cluster content and decrypting fields to use in workflows
+            workflow_content = {
+                "cluster": self.decrypted_copy(db_cluster),
+            }
 
-        # To get the vim account details
-        db_vim = self.db.get_one("vim_accounts", {"name": db_cluster["vim_account"]})
-        workflow_content["vim_account"] = db_vim
+            # To get the vim account details
+            db_vim = self.db.get_one(
+                "vim_accounts", {"name": db_cluster["vim_account"]}
+            )
+            workflow_content["vim_account"] = db_vim
+        except Exception as e:
+            self.logger.debug(traceback.format_exc())
+            self.logger.debug(f"Exception: {e}", exc_info=True)
+            raise e
 
         workflow_res, workflow_name = await self.odu.launch_workflow(
             "delete_cluster", op_id, op_params, workflow_content