diff --git a/src/assisted_test_infra/test_infra/helper_classes/cluster.py b/src/assisted_test_infra/test_infra/helper_classes/cluster.py index 0f883c30629..00fef2da425 100644 --- a/src/assisted_test_infra/test_infra/helper_classes/cluster.py +++ b/src/assisted_test_infra/test_infra/helper_classes/cluster.py @@ -45,7 +45,6 @@ def __init__( super().__init__(api_client, config, infra_env_config, nodes) - self._high_availability_mode = config.high_availability_mode self.name = config.cluster_name.get() @property @@ -65,6 +64,10 @@ def is_installed(self) -> bool: def enable_image_download(self): return self._config.download_image + @property + def control_plane_count(self): + return self._config.control_plane_count + @property def high_availability_mode(self): return self._config.high_availability_mode @@ -78,6 +81,7 @@ def _update_existing_cluster_config(self, api_client: InventoryClient, cluster_i entity_name=ClusterName(existing_cluster.name), additional_ntp_source=existing_cluster.additional_ntp_source, user_managed_networking=existing_cluster.user_managed_networking, + control_plane_count=existing_cluster.control_plane_count, high_availability_mode=existing_cluster.high_availability_mode, olm_operators=existing_cluster.monitored_operators, base_dns_domain=existing_cluster.base_dns_domain, @@ -132,9 +136,6 @@ def _create(self) -> str: if self._config.registry_ca_path: extra_vars["registry_ca_path"] = self._config.registry_ca_path - if self.nodes.masters_count and self.nodes.masters_count > 3: - extra_vars["control_plane_count"] = self.nodes.masters_count - if self._config.load_balancer_type == consts.LoadBalancerType.USER_MANAGED.value: extra_vars["load_balancer"] = {"type": self._config.load_balancer_type} @@ -151,6 +152,7 @@ def _create(self) -> str: base_dns_domain=self._config.base_dns_domain, additional_ntp_source=self._config.additional_ntp_source, user_managed_networking=self._config.user_managed_networking, + control_plane_count=self._config.control_plane_count, high_availability_mode=self._config.high_availability_mode, disk_encryption=disk_encryption, tags=self._config.cluster_tags or None, @@ -382,7 +384,7 @@ def set_network_params(self, controller=None): log.info("On None/External platforms, leaving network management to the user") api_vips = ingress_vips = machine_networks = None - elif self._config.vip_dhcp_allocation or self._high_availability_mode == consts.HighAvailabilityMode.NONE: + elif self._config.vip_dhcp_allocation or self.control_plane_count == consts.ControlPlaneCount.ONE: log.info("Letting access VIPs be deducted from machine networks") api_vips = ingress_vips = None machine_networks = [self.get_machine_networks()[0]] @@ -935,7 +937,7 @@ def wait_for_install(self, timeout=consts.CLUSTER_INSTALLATION_TIMEOUT): ) def _ha_not_none_not_external(self): - return self._high_availability_mode != consts.HighAvailabilityMode.NONE and self._config.platform not in [ + return self.control_plane_count != consts.ControlPlaneCount.ONE and self._config.platform not in [ consts.Platforms.NONE, consts.Platforms.EXTERNAL, ] @@ -948,7 +950,7 @@ def prepare_nodes(self, is_static_ip: bool = False, **kwargs): and platform.external.platform_name == consts.ExternalPlatformNames.OCI ) # required to test against stage/production # Patch for SNO OCI - currently not supported in the service self.set_hostnames_and_roles() - if self._high_availability_mode != consts.HighAvailabilityMode.NONE: + if self.control_plane_count != consts.ControlPlaneCount.ONE: self.set_host_roles(len(self.nodes.get_masters()), len(self.nodes.get_workers())) self.set_installer_args() @@ -1008,7 +1010,7 @@ def prepare_networking(self): ): self._configure_load_balancer() self.nodes.controller.set_dns_for_user_managed_network() - elif self._high_availability_mode == consts.HighAvailabilityMode.NONE: + elif self.control_plane_count == consts.ControlPlaneCount.ONE: main_cidr = self.get_primary_machine_cidr() ip = Cluster.get_ip_for_single_node(self.api_client, self.id, main_cidr) self.nodes.controller.set_single_node_ip(ip) diff --git a/src/assisted_test_infra/test_infra/helper_classes/config/base_entity_config.py b/src/assisted_test_infra/test_infra/helper_classes/config/base_entity_config.py index 1e0d71b3fdd..f3e37860c88 100644 --- a/src/assisted_test_infra/test_infra/helper_classes/config/base_entity_config.py +++ b/src/assisted_test_infra/test_infra/helper_classes/config/base_entity_config.py @@ -15,6 +15,7 @@ class BaseEntityConfig(BaseConfig, ABC): openshift_version: str = None additional_ntp_source: str = None user_managed_networking: bool = None + control_plane_count: str = None high_availability_mode: str = None hyperthreading: str = None iso_download_path: str = None # TODO Needed only on infra env. Remove from here and move to BaseInfraEnvConfig diff --git a/src/consts/consts.py b/src/consts/consts.py index 5e73e0360d2..8918a22586d 100644 --- a/src/consts/consts.py +++ b/src/consts/consts.py @@ -329,6 +329,11 @@ class KubeAPIPlatforms: VSPHERE = "VSphere" +class ControlPlaneCount: + THREE = 3 + ONE = 1 + + class HighAvailabilityMode: FULL = "Full" NONE = "None" diff --git a/src/consts/env_defaults.py b/src/consts/env_defaults.py index 73522d234f8..b890b749436 100644 --- a/src/consts/env_defaults.py +++ b/src/consts/env_defaults.py @@ -16,7 +16,7 @@ DEFAULT_TEST_TEARDOWN: bool = True DEFAULT_PLATFORM: str = consts.Platforms.BARE_METAL DEFAULT_USER_MANAGED_NETWORKING: bool = False -DEFAULT_HIGH_AVAILABILITY_MODE: str = consts.HighAvailabilityMode.FULL +DEFAULT_CONTROL_PLANE_COUNT: int = consts.ControlPlaneCount.THREE DEFAULT_DOWNLOAD_IMAGE: bool = True DEFAULT_VERIFY_SSL: bool = True DEFAULT_IS_IPV4: bool = True diff --git a/src/tests/global_variables/env_variables_defaults.py b/src/tests/global_variables/env_variables_defaults.py index c43593e0f46..28429effcce 100644 --- a/src/tests/global_variables/env_variables_defaults.py +++ b/src/tests/global_variables/env_variables_defaults.py @@ -95,7 +95,8 @@ class _EnvVariables(DataPool, ABC): loader=lambda x: bool(strtobool(x)), default=env_defaults.DEFAULT_USER_MANAGED_NETWORKING, ) - high_availability_mode: EnvVar = EnvVar(default=env_defaults.DEFAULT_HIGH_AVAILABILITY_MODE) + control_plane_count: EnvVar = EnvVar(default=env_defaults.DEFAULT_CONTROL_PLANE_COUNT) + high_availability_mode: EnvVar = EnvVar(default=consts.HighAvailabilityMode.FULL) download_image: EnvVar = EnvVar( ["DOWNLOAD_IMAGE"], loader=lambda x: bool(strtobool(x)), default=env_defaults.DEFAULT_DOWNLOAD_IMAGE ) diff --git a/src/triggers/default_triggers.py b/src/triggers/default_triggers.py index cb22f32469b..3ac003a2e19 100644 --- a/src/triggers/default_triggers.py +++ b/src/triggers/default_triggers.py @@ -34,6 +34,7 @@ "sno": Trigger( conditions=[lambda config: config.masters_count == 1], workers_count=0, + control_plane_count=consts.ControlPlaneCount.ONE, high_availability_mode=consts.HighAvailabilityMode.NONE, user_managed_networking=True, master_memory=resources.DEFAULT_MASTER_SNO_MEMORY,