From 2048e8395fb4274b56c43e03c4eccb243eae6d98 Mon Sep 17 00:00:00 2001 From: Suchita Gatfane Date: Mon, 29 Aug 2022 17:08:26 +0530 Subject: [PATCH] Quick for addon based deployment using byo-vpc ODFMS-262 (#6371) Quick Fixes ODFMS-262 using existing byo-vpc Default exiting byo-vpc will be used for cluster creation. Default subnet configuration can be overwrite with config parameter subnet_ids or vpc_name ex: ENV_DATA: subnet_ids: subnet-123xyz1,subnet-subnet-123xyz2,subnet-subnet-123xyz3 or ENV_DATA: vpc_name: qe-am-triage Signed-off-by: suchita.gatfane --- ocs_ci/utility/rosa.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/ocs_ci/utility/rosa.py b/ocs_ci/utility/rosa.py index c6bfc115c11..9e083f4d1fe 100644 --- a/ocs_ci/utility/rosa.py +++ b/ocs_ci/utility/rosa.py @@ -3,7 +3,6 @@ Module for interactions with Openshift Dedciated Cluster. """ - import json import logging import os @@ -25,7 +24,6 @@ get_storage_provider_endpoint, ) - logger = logging.getLogger(name=__file__) rosa = config.AUTH.get("rosa", {}) @@ -68,8 +66,6 @@ def create_cluster(cluster_name, version, region): compute_nodes = config.ENV_DATA["worker_replicas"] compute_machine_type = config.ENV_DATA["worker_instance_type"] multi_az = "--multi-az " if config.ENV_DATA.get("multi_availability_zones") else "" - cluster_type = config.ENV_DATA.get("cluster_type", "") - provider_name = config.ENV_DATA.get("provider_name", "") rosa_mode = config.ENV_DATA.get("rosa_mode", "") private_link = config.ENV_DATA.get("private_link", False) machine_cidr = config.ENV_DATA.get("machine-cidr", "10.0.0.0/16") @@ -82,28 +78,29 @@ def create_cluster(cluster_name, version, region): if rosa_mode == "auto": cmd += " --mode auto" - if ( - config.ENV_DATA.get("appliance_mode", False) - and config.ENV_DATA.get("cluster_type", "") == "consumer" - ): + # OCM has a check for byo-vpc and now onwards use of osd vpc is result into + # https://issues.redhat.com/browse/ODFMS-262 + # hence Addon based and appliance mode provider consumer must use byo-vpc. + # For quick fix we can use existing byo-vpc for all deployment as default + # The implementation is still flexi to provide subnets or vpc name from env parameter + # if parameters are not defined then existing byo-vpc will be used + if config.ENV_DATA.get("subnet_ids", ""): + subnet_ids = config.ENV_DATA.get("subnet_ids") + elif config.ENV_DATA.get("vpc_name", ""): + aws = AWSUtil() + subnet_ids = ",".join( + aws.get_cluster_subnet_ids(config.ENV_DATA.get("vpc_name")) + ) + # TODO: improve this for enabling it for selecting private and public subnets + # separately. This will enable to create private link cluster using byo-vpc name + else: subnet_ids = config.ENV_DATA["ms_provider_subnet_ids_per_region"][region][ "private_subnet" ] if not private_link: subnet_ids += f",{config.ENV_DATA['ms_provider_subnet_ids_per_region'][region]['public_subnet']}" - cmd = f"{cmd} --subnet-ids {subnet_ids}" + cmd = f"{cmd} --subnet-ids {subnet_ids}" - elif cluster_type.lower() == "consumer" and config.ENV_DATA.get( - "provider_name", "" - ): - aws = AWSUtil() - subnet_id = config.ENV_DATA.get("subnet_ids") or ",".join( - aws.get_cluster_subnet_ids(provider_name) - ) - cmd = f"{cmd} --subnet-ids {subnet_id}" - elif cluster_type.lower() == "provider" and config.ENV_DATA.get("subnet_ids"): - subnet_id = config.ENV_DATA.get("subnet_ids") - cmd = f"{cmd} --subnet-ids {subnet_id}" if private_link: cmd += " --private-link " utils.run_cmd(cmd, timeout=1200)