Skip to content

Commit 9ad5fef

Browse files
committed
fix: older k8s api issue with LB IP extraction logic
1 parent 1b4f7fa commit 9ad5fef

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ jobs:
102102
fi
103103
- name: Run integration tests
104104
run: |
105-
tox run -e ${{ matrix.tox-environment }} -- -m '${{ steps.select-tests.outputs.mark_expression }}' --keep-models --kraft-mode=${{ matrix.kraft-mode }}
105+
tox run -e ${{ matrix.tox-environment }} -- -m '${{ steps.select-tests.outputs.mark_expression }}' --keep-models --kraft-mode=${{ matrix.kraft-mode }}

tests/integration/terraform/component_validation.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,21 @@ def test_ui_accessibility(self):
235235
"""Test that Kafka UI is accessible."""
236236
# Get LoadBalancer IP address
237237
raw = check_output(
238-
"microk8s.kubectl get services -A --field-selector spec.type=LoadBalancer -o json",
238+
"microk8s.kubectl get services -A -o json",
239239
shell=True,
240240
universal_newlines=True,
241241
stderr=PIPE,
242242
)
243243
lb_json = json.loads(raw)
244+
lb_ip = None
244245

245-
try:
246-
lb_ip = lb_json["items"][0]["status"]["loadBalancer"]["ingress"][0]["ip"]
247-
except (KeyError, IndexError) as e:
248-
raise Exception("Can't find LoadBalancer external IP") from e
246+
for item in lb_json["items"]:
247+
if item.get("spec", {}).get("type") == "LoadBalancer":
248+
lb_ip = item["status"]["loadBalancer"]["ingress"][0]["ip"]
249+
break
250+
251+
if not lb_ip:
252+
raise Exception("Can't find LoadBalancer external IP")
249253

250254
# Generate the URL for Kafka UI based on LB IP address
251255
url = f"https://{lb_ip}/{self.juju.model}-{KAFKA_UI_APP_NAME}"

tests/integration/terraform/helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def deploy_core_apps(ingress: str | None = None) -> None:
180180
if not ingress:
181181
core_juju.deploy(TRAEFIK_APP_NAME, trust=True)
182182
apps.add(TRAEFIK_APP_NAME)
183+
core_juju.integrate(CERTIFICATES_APP_NAME, f"{TRAEFIK_APP_NAME}:certificates")
183184

184185
core_juju.wait(
185186
lambda status: all_active_idle(status, *apps),

0 commit comments

Comments
 (0)