Fix deregistration workflow to clean secret after deletion workflow 09/14909/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 5 Feb 2025 08:32:52 +0000 (09:32 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 5 Feb 2025 08:32:52 +0000 (09:32 +0100)
Change-Id: I513d8d2748d332c32def3d4501858cdb8395bbaa
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/k8s.py

index 634f68b..0e68bc3 100644 (file)
@@ -1073,13 +1073,6 @@ class ClusterLcm(GitOpsLcm):
                 db_cluster, op_id, workflow_status=False, resource_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(
-                "deregister_cluster", op_id, op_params, workflow_content
-            )
-            self.logger.info(
-                f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
-            )
             return
 
         self.logger.info("workflow_name is: {}".format(workflow_name))
@@ -1102,14 +1095,6 @@ class ClusterLcm(GitOpsLcm):
         )
         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(
-            "deregister_cluster", op_id, op_params, workflow_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.check_resource_status(
                 "deregister_cluster", op_id, op_params, workflow_content
@@ -1129,7 +1114,15 @@ class ClusterLcm(GitOpsLcm):
         )
         self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
 
-        return await self.delete(params, order_id)
+        await self.delete(params, order_id)
+        # 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(
+            "deregister_cluster", op_id, op_params, workflow_content
+        )
+        self.logger.info(
+            f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+        )
+        return
 
     async def get_creds(self, params, order_id):
         self.logger.info("Cluster get creds Enter")