From: garciadeblas Date: Thu, 24 Oct 2024 10:52:11 +0000 (+0200) Subject: Update list of checks for AWS and GCP cluster creation X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F14674%2F4;p=osm%2FLCM.git Update list of checks for AWS and GCP cluster creation Change-Id: I7ae53a6098b10cea1deeb93979dfee165fbb2d84 Signed-off-by: garciadeblas --- diff --git a/osm_lcm/odu_libs/cluster_mgmt.py b/osm_lcm/odu_libs/cluster_mgmt.py index 1c21675..a3c821b 100644 --- a/osm_lcm/odu_libs/cluster_mgmt.py +++ b/osm_lcm/odu_libs/cluster_mgmt.py @@ -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) diff --git a/osm_lcm/odu_libs/workflows.py b/osm_lcm/odu_libs/workflows.py index a95e982..61b9353 100644 --- a/osm_lcm/odu_libs/workflows.py +++ b/osm_lcm/odu_libs/workflows.py @@ -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}"