Removing cluster deregister workaround 62/14862/6
authorshrinithi <shrinithi.r@tataelxsi.co.in>
Fri, 10 Jan 2025 10:58:12 +0000 (10:58 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 5 Feb 2025 08:23:57 +0000 (09:23 +0100)
Change-Id: Ibcf79b9ae29353721f9118d2f6871e84833c1b1e
Signed-off-by: shrinithi <shrinithi.r@tataelxsi.co.in>
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/k8s.py

index 952760e..634f68b 100644 (file)
@@ -434,7 +434,6 @@ class ClusterLcm(GitOpsLcm):
         self.logger.info(
             f"check_create_cluster Operation {op_id}. Params: {op_params}."
         )
-        # self.logger.debug(f"Content: {content}")
         db_cluster = content["cluster"]
         cluster_name = db_cluster["git_name"].lower()
         cluster_kustomization_name = cluster_name
@@ -536,7 +535,6 @@ class ClusterLcm(GitOpsLcm):
         self.logger.info("the db_cluster is :{}".format(db_cluster))
         for profile_type in profiles:
             profile_id = db_cluster[profile_type]
-            # db_collection = profiles_collection[profile_type]
             db_collection = self.profile_collection_mapping[profile_type]
             db_profile = self.db.get_one(db_collection, {"_id": profile_id})
             op_id = db_profile["operationHistory"][-1].get("op_id")
@@ -575,11 +573,6 @@ class ClusterLcm(GitOpsLcm):
         db_vim = self.db.get_one("vim_accounts", {"name": db_cluster["vim_account"]})
         workflow_content["vim_account"] = db_vim
 
-        # TODO: workaround until NBI rejects cluster deletion requests for registered clusters
-        # This if clause will be removed
-        if db_cluster["created"] == "false":
-            return await self.deregister(params, order_id)
-
         workflow_res, workflow_name = await self.odu.launch_workflow(
             "delete_cluster", op_id, op_params, workflow_content
         )
@@ -700,9 +693,6 @@ class ClusterLcm(GitOpsLcm):
 
     def delete_cluster(self, db_cluster):
         # Actually, item_content is equal to db_cluster
-        # item_content = self.db.get_one("clusters", {"_id": db_cluster["_id"]})
-        # self.logger.debug("item_content is : {}".format(item_content))
-
         # detach profiles
         update_dict = None
         profiles_to_detach = [
@@ -724,7 +714,6 @@ class ClusterLcm(GitOpsLcm):
                 profile_ids = db_cluster[profile_type]
                 profile_ids_copy = deepcopy(profile_ids)
                 for profile_id in profile_ids_copy:
-                    # db_collection = profiles_collection[profile_type]
                     db_collection = self.profile_collection_mapping[profile_type]
                     db_profile = self.db.get_one(db_collection, {"_id": profile_id})
                     self.logger.debug("the db_profile is :{}".format(db_profile))
@@ -859,7 +848,6 @@ class ClusterLcm(GitOpsLcm):
         profile_collection = self.profile_collection_mapping[profile_type]
         db_profile = self.db.get_one(profile_collection, {"_id": profile_id})
         db_profile["profile_type"] = profile_type
-        # content["profile"] = db_profile
         workflow_content["profile"] = db_profile
 
         workflow_res, workflow_name = await self.odu.launch_workflow(
@@ -1139,9 +1127,6 @@ class ClusterLcm(GitOpsLcm):
         db_cluster = self.update_operation_history(
             db_cluster, op_id, workflow_status, resource_status
         )
-        # TODO: workaround until NBI rejects cluster deletion requests for registered clusters
-        # Setting created flag to true avoids infinite loops when deregistering a cluster
-        db_cluster["created"] = "true"
         self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
 
         return await self.delete(params, order_id)