Skip to content

Commit

Permalink
Mgmt-19419: replace HighAvailabilityMode with ControlPlaneCount - pha…
Browse files Browse the repository at this point in the history
…se 1 (#2632)

* starting to remove the reference for high_availability_mode

* MGMT-19419: remove all reference of HighAvailabilityMode

* adding back some high_availability_mode so it would be compatible with assisted-service
  • Loading branch information
andrej1991 authored Feb 25, 2025
1 parent 1802a62 commit 6681f8e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/assisted_test_infra/test_infra/helper_classes/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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}

Expand All @@ -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,
Expand Down Expand Up @@ -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]]
Expand Down Expand Up @@ -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,
]
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/consts/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ class KubeAPIPlatforms:
VSPHERE = "VSphere"


class ControlPlaneCount:
THREE = 3
ONE = 1


class HighAvailabilityMode:
FULL = "Full"
NONE = "None"
Expand Down
2 changes: 1 addition & 1 deletion src/consts/env_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/tests/global_variables/env_variables_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
1 change: 1 addition & 0 deletions src/triggers/default_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6681f8e

Please sign in to comment.