Fix condition to check for AWS cluster scale, rename nodepool to nodegroup 10/15210/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 30 May 2025 09:19:06 +0000 (11:19 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 3 Jun 2025 09:31:03 +0000 (11:31 +0200)
Change-Id: I9618fa83a009c803b55565c6f6cc675537875f87
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/k8s.py
osm_lcm/odu_libs/workflows.py

index 83f57e4..3a2d8b7 100644 (file)
@@ -517,12 +517,12 @@ class ClusterLcm(GitOpsLcm):
         cluster_kustomization_name = cluster_name
         db_vim_account = content["vim_account"]
         cloud_type = db_vim_account["vim_type"]
-        nodepool_name = ""
+        nodegroup_name = ""
         if cloud_type == "aws":
-            nodepool_name = f"{cluster_name}-nodegroup"
+            nodegroup_name = f"{cluster_name}-nodegroup"
             cluster_name = f"{cluster_name}-cluster"
         elif cloud_type == "gcp":
-            nodepool_name = f"nodepool-{cluster_name}"
+            nodegroup_name = f"nodepool-{cluster_name}"
         bootstrap = op_params.get("bootstrap", True)
         if cloud_type in ("azure", "gcp", "aws"):
             checkings_list = [
@@ -577,10 +577,10 @@ class ClusterLcm(GitOpsLcm):
             ]
         else:
             return False, "Not suitable VIM account to check cluster status"
-        if nodepool_name:
-            nodepool_check = {
-                "item": f"nodepool_{cloud_type}",
-                "name": nodepool_name,
+        if nodegroup_name:
+            nodegroup_check = {
+                "item": f"nodegroup_{cloud_type}",
+                "name": nodegroup_name,
                 "namespace": "",
                 "condition": {
                     "jsonpath_filter": "status.conditions[?(@.type=='Ready')].status",
@@ -588,9 +588,9 @@ class ClusterLcm(GitOpsLcm):
                 },
                 "timeout": self._checkloop_resource_timeout,
                 "enable": True,
-                "resourceState": "IN_PROGRESS.RESOURCE_READY.NODEPOOL",
+                "resourceState": "IN_PROGRESS.RESOURCE_READY.NODEGROUP",
             }
-            checkings_list.insert(3, nodepool_check)
+            checkings_list.insert(3, nodegroup_check)
         return await self.common_check_list(
             op_id, checkings_list, "clusters", db_cluster
         )
@@ -1384,20 +1384,37 @@ class ClusterLcm(GitOpsLcm):
             return False, "Not suitable VIM account to check cluster status"
         # Scale operation
         if "node_count" in op_params:
-            checkings_list.append(
-                {
-                    "item": f"cluster_{cloud_type}",
-                    "name": cluster_name,
-                    "namespace": "",
-                    "condition": {
-                        "jsonpath_filter": "status.atProvider.defaultNodePool[0].nodeCount",
-                        "value": f"{op_params['node_count']}",
-                    },
-                    "timeout": self._checkloop_resource_timeout * 3,
-                    "enable": True,
-                    "resourceState": "IN_PROGRESS.RESOURCE_READY.NODE_COUNT.CLUSTER",
-                }
-            )
+            if cloud_type in ("azure", "gcp"):
+                checkings_list.append(
+                    {
+                        "item": f"cluster_{cloud_type}",
+                        "name": cluster_name,
+                        "namespace": "",
+                        "condition": {
+                            "jsonpath_filter": "status.atProvider.defaultNodePool[0].nodeCount",
+                            "value": f"{op_params['node_count']}",
+                        },
+                        "timeout": self._checkloop_resource_timeout * 3,
+                        "enable": True,
+                        "resourceState": "IN_PROGRESS.RESOURCE_READY.NODE_COUNT.CLUSTER",
+                    }
+                )
+            elif cloud_type == "aws":
+                checkings_list.append(
+                    {
+                        "item": f"nodegroup_{cloud_type}",
+                        "name": f"{cluster_name}-nodegroup",
+                        "namespace": "",
+                        "condition": {
+                            "jsonpath_filter": "status.atProvider.scalingConfig[0].desiredSize",
+                            "value": f"{op_params['node_count']}",
+                        },
+                        "timeout": self._checkloop_resource_timeout * 3,
+                        "enable": True,
+                        "resourceState": "IN_PROGRESS.RESOURCE_READY.NODE_COUNT.CLUSTER",
+                    }
+                )
+
         # Upgrade operation
         if "k8s_version" in op_params:
             checkings_list.append(
index 55163e7..92c4602 100644 (file)
@@ -94,12 +94,12 @@ async def readiness_loop(
             "api_plural": "clusters",
             "api_version": "v1beta2",
         },
-        "nodepool_aws": {
+        "nodegroup_aws": {
             "api_group": "eks.aws.upbound.io",
             "api_plural": "nodegroups",
             "api_version": "v1beta1",
         },
-        "nodepool_gcp": {
+        "nodegroup_gcp": {
             "api_group": "container.gcp.upbound.io",
             "api_plural": "nodepools",
             "api_version": "v1beta2",