Skip to content

Commit 5d7f156

Browse files
committed
feat(collector): detect Istio installation type in info collector
Signed-off-by: Silvia Tarabova <starabov@redhat.com>
1 parent 78f7d32 commit 5d7f156

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

testsuite/component_metadata.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ def get_component_images(project) -> list[tuple]:
127127

128128
return images
129129

130+
@staticmethod
131+
def get_istio_type(cluster) -> tuple[str, Optional[str]]:
132+
"""Determine Istio installation type and namespace from cluster-wide Istio CRs.
133+
134+
Returns (istio_type, namespace) where istio_type is one of:
135+
- "gateway-api-managed" with "openshift-ingress"
136+
- "user-managed-ossm" with "istio-system"
137+
- "none" with None
138+
"""
139+
try:
140+
with cluster.context:
141+
istios = oc.selector("Istio", all_namespaces=True).objects()
142+
if not istios:
143+
return "none", None
144+
if any(i.name() == "openshift-gateway" for i in istios):
145+
return "gateway-api-managed", "openshift-ingress"
146+
return "user-managed-ossm", "istio-system"
147+
except (oc.OpenShiftPythonException, AttributeError, KeyError) as e:
148+
logger.warning("Failed to detect Istio type: %s", e)
149+
return "none", None
150+
130151
@staticmethod
131152
def get_istio_metadata(project) -> dict[str, str]:
132153
"""Get Istio version and istiod image from the cluster."""

testsuite/tests/info_collector.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,22 @@ def test_kuadrant_properties(record_testsuite_property):
130130

131131

132132
def test_istio_properties(record_testsuite_property):
133-
"""Record Istio related properties from all clusters."""
133+
"""Record Istio installation type and metadata from all clusters."""
134134
properties = []
135135
cluster_data = {}
136-
for cluster_name, _, project in _all_cluster_projects("istio-system"):
137-
if project is None:
138-
cluster_data[cluster_name] = ["namespace 'istio-system' not found"]
136+
for cluster_name, cluster, _ in _all_cluster_projects("default"):
137+
istio_type, namespace = ReportPortalMetadataCollector.get_istio_type(cluster)
138+
cluster_data[cluster_name] = [f"istio_type:{istio_type}"]
139+
properties.append(("istio_type", istio_type))
140+
141+
if namespace is None:
139142
continue
140-
cluster_data[cluster_name] = []
143+
144+
project = cluster.change_project(namespace)
145+
if not project.connected:
146+
cluster_data[cluster_name].append(f"namespace '{namespace}' not found")
147+
continue
148+
141149
istio_metadata = ReportPortalMetadataCollector.get_istio_metadata(project)
142150
for key, value in istio_metadata.items():
143151
cluster_data[cluster_name].append(f"{key}:{value}")

0 commit comments

Comments
 (0)