Skip to content

Commit 0116f05

Browse files
authored
[IUO] Fix webhook test failure for dynamic webhook configurations (RedHatQE#2307)
Fix TypeError in test_webhookconfig_resources when processing webhook │ configurations with null/empty webhooks field. │ │ The test was failing with "TypeError: 'NoneType' object is not subscriptable" │ when iterating over webhook configurations that have no webhooks defined. │ This occurs with Tekton Pipelines/Triggers webhooks (config.webhook.pipeline.tekton.dev │ and config.webhook.triggers.tekton.dev) which use dynamic webhook configuration │ patterns where the ValidatingWebhookConfiguration is created empty and populated │ later by the webhook controller. │ │ Changes: │ - Add null/empty check before accessing webhook_resource.instance.webhooks[0] │ - Log warning with webhook name and type when skipping unconfigured webhooks │ - Prevent test failures in clusters with OpenShift Pipelines installed │ │
1 parent 458ea52 commit 0116f05

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • tests/install_upgrade_operators/must_gather

tests/install_upgrade_operators/must_gather/utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from ocp_resources.resource import Resource
1414
from ocp_resources.service import Service
1515

16-
from utilities.constants import NamespacesNames
16+
from tests.install_upgrade_operators.relationship_labels.constants import PART_OF_LABEL_KEY
17+
from utilities.constants import HCO_PART_OF_LABEL_VALUE, NamespacesNames
1718
from utilities.data_collector import get_data_collector_base_directory
1819
from utilities.infra import ResourceMismatch
1920

@@ -249,6 +250,15 @@ def check_logs(cnv_must_gather, running_hco_containers, namespace, label_selecto
249250

250251
def compare_webhook_svc_contents(webhook_resources, cnv_must_gather, dyn_client, checks):
251252
for webhook_resource in webhook_resources:
253+
if not webhook_resource.instance.webhooks:
254+
if webhook_resource.labels.get(PART_OF_LABEL_KEY) == HCO_PART_OF_LABEL_VALUE:
255+
raise AssertionError(
256+
f"CNV webhook '{webhook_resource.name}' ({webhook_resource.kind}) has no webhooks configured."
257+
)
258+
else:
259+
LOGGER.warning(f"Non-CNV webhook '{webhook_resource.name}' has no webhooks configured.")
260+
continue
261+
252262
if webhook_resource.kind == "MutatingWebhookConfiguration":
253263
service_file = os.path.join(
254264
cnv_must_gather,

0 commit comments

Comments
 (0)