Update list of checks for AWS and GCP cluster creation 74/14674/4
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 24 Oct 2024 10:52:11 +0000 (12:52 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 29 Oct 2024 10:15:40 +0000 (11:15 +0100)
Change-Id: I7ae53a6098b10cea1deeb93979dfee165fbb2d84
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/odu_libs/cluster_mgmt.py
osm_lcm/odu_libs/workflows.py

index 1c21675..a3c821b 100644 (file)
@@ -442,44 +442,60 @@ async def check_create_cluster(self, op_id, op_params, content):
     cluster_kustomization_name = cluster_name
     db_vim_account = content["vim_account"]
     cloud_type = db_vim_account["vim_type"]
+    nodepool_name = ""
+    if cloud_type == "aws":
+        nodepool_name = f"{cluster_name}-nodegroup"
+        cluster_name = f"{cluster_name}-cluster"
+    elif cloud_type == "gcp":
+        nodepool_name = f"nodepool-{cluster_name}"
     bootstrap = op_params.get("bootstrap", True)
-    if cloud_type not in ("azure", "gcp", "aws"):
+    if cloud_type in ("azure", "gcp", "aws"):
+        checkings_list = [
+            {
+                "item": "kustomization",
+                "name": cluster_kustomization_name,
+                "namespace": "managed-resources",
+                "flag": "Ready",
+                "timeout": self._odu_checkloop_kustomization_timeout,
+                "enable": True,
+            },
+            {
+                "item": f"cluster_{cloud_type}",
+                "name": cluster_name,
+                "namespace": "",
+                "flag": "Synced",
+                "timeout": self._odu_checkloop_resource_timeout,
+                "enable": True,
+            },
+            {
+                "item": f"cluster_{cloud_type}",
+                "name": cluster_name,
+                "namespace": "",
+                "flag": "Ready",
+                "timeout": self._odu_checkloop_resource_timeout,
+                "enable": True,
+            },
+            {
+                "item": "kustomization",
+                "name": f"{cluster_kustomization_name}-bstrp-fluxctrl",
+                "namespace": "managed-resources",
+                "flag": "Ready",
+                "timeout": self._odu_checkloop_kustomization_timeout,
+                "enable": bootstrap,
+            },
+        ]
+    else:
         return False, "Not suitable VIM account to check cluster status"
-
-    checkings_list = [
-        {
-            "item": "kustomization",
-            "name": cluster_kustomization_name,
-            "namespace": "managed-resources",
-            "flag": "Ready",
-            "timeout": self._odu_checkloop_kustomization_timeout,
-            "enable": True,
-        },
-        {
-            "item": f"cluster_{cloud_type}",
-            "name": cluster_name,
-            "namespace": "",
-            "flag": "Synced",
-            "timeout": self._odu_checkloop_resource_timeout,
-            "enable": True,
-        },
-        {
-            "item": f"cluster_{cloud_type}",
-            "name": cluster_name,
+    if nodepool_name:
+        nodepool_check = {
+            "item": f"nodepool_{cloud_type}",
+            "name": nodepool_name,
             "namespace": "",
             "flag": "Ready",
             "timeout": self._odu_checkloop_resource_timeout,
             "enable": True,
-        },
-        {
-            "item": "kustomization",
-            "name": f"{cluster_kustomization_name}-bstrp-fluxctrl",
-            "namespace": "managed-resources",
-            "flag": "Ready",
-            "timeout": self._odu_checkloop_kustomization_timeout,
-            "enable": bootstrap,
-        },
-    ]
+        }
+        checkings_list.insert(3, nodepool_check)
     return await self.common_check_list(checkings_list)
 
 
index a95e982..61b9353 100644 (file)
@@ -18,6 +18,7 @@
 
 import asyncio
 import traceback
+import yaml
 from math import ceil
 
 
@@ -38,7 +39,7 @@ async def check_workflow_status(self, workflow_name):
 async def readiness_loop(self, item, name, namespace, flag, timeout):
     self.logger.info("readiness_loop Enter")
     self.logger.info(
-        f"{item} {name}. Namespace: {namespace}. Flag: {flag}. Timeout: {timeout}"
+        f"{item} {name}. Namespace: '{namespace}'. Flag: {flag}. Timeout: {timeout}"
     )
     item_api_map = {
         "workflow": {
@@ -66,6 +67,16 @@ async def readiness_loop(self, item, name, namespace, flag, timeout):
             "api_plural": "clusters",
             "api_version": "v1beta2",
         },
+        "nodepool_aws": {
+            "api_group": "eks.aws.upbound.io",
+            "api_plural": "nodegroups",
+            "api_version": "v1beta1",
+        },
+        "nodepool_gcp": {
+            "api_group": "container.gcp.upbound.io",
+            "api_plural": "nodepools",
+            "api_version": "v1beta2",
+        },
     }
     counter = 1
     retry_time = self._odu_checkloop_retry_time
@@ -83,9 +94,12 @@ async def readiness_loop(self, item, name, namespace, flag, timeout):
             name=name,
         )
         if generic_object:
-            self.logger.debug(f"{yaml.safe_dump(generic_object)}")
+            self.logger.debug(f"{yaml.safe_dump(generic_object)}")
             conditions = generic_object.get("status", {}).get("conditions", [])
         else:
+            self.logger.debug(
+                f"Could not find {api_plural}. Name: {name}. Namespace: '{namespace}'. API: {api_group}/{api_version}"
+            )
             conditions = []
         self.logger.info(
             f"Iteration {counter}/{max_iterations}. {item} status conditions: {conditions}"