Skip to content

Commit

Permalink
MGMT-19684: Enable automatic testing of user managed load balancer wi…
Browse files Browse the repository at this point in the history
…th hosts in the same subnet but load balancer outside this subnet on baremetal for k8s API flow (#2608)

Co-authored-by: root <[email protected]>
  • Loading branch information
danmanor and root authored Jan 13, 2025
1 parent e65cad9 commit 1b79116
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,9 @@ test_ctlplane_scaleup:

install_k8s_api:
TEST_TEARDOWN=false TEST=./src/tests/test_kube_api.py TEST_FUNC=test_kubeapi $(MAKE) test

destroy_crs:
oc delete cd --all-namespaces --all
oc delete aci --all-namespaces --all
oc delete infraenv --all-namespaces --all
oc delete agents --all-namespaces --all
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,12 @@ def patch(self, **kwargs) -> None:

log.info("patching agentclusterinstall %s: %s", self.ref, pformat(body))

def set_machinenetwork(self, machine_cidr):
self.patch(
networking={
"machineNetwork": [
{
"cidr": machine_cidr,
}
]
}
)
def set_machine_networks(self, machine_cidrs):
machine_networks: list[dict[str, str]] = []
for machine_cidr in machine_cidrs:
machine_networks.append({"cidr": machine_cidr})

self.patch(networking={"machineNetwork": machine_networks})

def set_api_vip(self, vip):
self.patch(apiVIPs=[vip])
Expand Down
2 changes: 1 addition & 1 deletion src/tests/base_kubeapi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _wait_for_install(
@classmethod
def _set_agent_cluster_install_machine_cidr(cls, agent_cluster_install: AgentClusterInstall, nodes: Nodes):
machine_cidr = nodes.controller.get_primary_machine_cidr()
agent_cluster_install.set_machinenetwork(machine_cidr)
agent_cluster_install.set_machine_networks([machine_cidr])

@classmethod
def download_iso_from_infra_env(cls, infra_env: InfraEnv, iso_download_path: str):
Expand Down
10 changes: 5 additions & 5 deletions src/tests/test_kube_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ def kube_api_test(
api_vip = ingress_vip = load_balancer_ip
agent_cluster_install.set_api_vip(api_vip)
agent_cluster_install.set_ingress_vip(ingress_vip)
primary_machine_cidr = nodes.controller.get_primary_machine_cidr()
agent_cluster_install.set_machine_networks(
[primary_machine_cidr, consts.DEFAULT_LOAD_BALANCER_NETWORK_CIDR]
)
else:
# patch the aci with the vips. The cidr will be derived from the range
access_vips = nodes.controller.get_ingress_and_api_vips()
api_vip = access_vips["api_vips"][0].get("ip", "") if len(access_vips["api_vips"]) > 0 else ""
ingress_vip = access_vips["ingress_vips"][0].get("ip", "") if len(access_vips["ingress_vips"]) > 0 else ""
Expand Down Expand Up @@ -235,10 +238,7 @@ def does_agent_has_ip() -> bool:
def configure_load_balancer(
self, nodes: Nodes, infraenv: InfraEnv, aci: AgentClusterInstall, cluster_config: ClusterConfig
) -> str:
aci_resource = aci.get()
machine_cidr = get_field_from_resource(resource=aci_resource, path="spec.networking.machineNetwork[0].cidr")
log.info(f"Got cluster machine CIDR: {machine_cidr}")
load_balancer_ip = str(IPNetwork(machine_cidr).ip + 1)
load_balancer_ip = str(IPNetwork(consts.DEFAULT_LOAD_BALANCER_NETWORK_CIDR).ip + 1)
log.info(f"Calculated load balancer IP: {load_balancer_ip}")

agents = infraenv.list_agents()
Expand Down

0 comments on commit 1b79116

Please sign in to comment.