From 18aa0d2776d25d96b696d2b9576f659e764e6f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Wed, 10 Jul 2024 12:53:28 +0200 Subject: [PATCH] fix: fix listing ValidatingWebhookConfiguration using old labels --- controller/controlplane/controller_reconciler_utils.go | 5 +++-- test/helpers/setup.go | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/controller/controlplane/controller_reconciler_utils.go b/controller/controlplane/controller_reconciler_utils.go index 699b28b3f..e0282014e 100644 --- a/controller/controlplane/controller_reconciler_utils.go +++ b/controller/controlplane/controller_reconciler_utils.go @@ -648,10 +648,11 @@ func (r *Reconciler) ensureOwnedClusterRoleBindingsDeleted( func (r *Reconciler) ensureOwnedValidatingWebhookConfigurationDeleted(ctx context.Context, cp *operatorv1beta1.ControlPlane, ) (deletions bool, err error) { - // TODO: Remove listing with old labels https://github.com/Kong/gateway-operator/issues/401. - validatingWebhookConfigurationsLegacy, err := k8sutils.ListValidatingWebhookConfigurations( + // TODO: Remove listing with old labels and owner ref https://github.com/Kong/gateway-operator/issues/401. + validatingWebhookConfigurationsLegacy, err := k8sutils.ListValidatingWebhookConfigurationsForOwner( ctx, r.Client, + cp.GetUID(), // NOTE: this uses only the 1 label to find the legacy webhook configurations not the label set // because app: is not set on ValidatingWebhookConfiguration. client.MatchingLabels(k8sutils.GetLegacyManagedByLabel(cp)), diff --git a/test/helpers/setup.go b/test/helpers/setup.go index 50bb870ff..78ce0d0c5 100644 --- a/test/helpers/setup.go +++ b/test/helpers/setup.go @@ -33,6 +33,9 @@ func SetupTestEnv(t *testing.T, ctx context.Context, env environments.Environmen t.Log("performing test setup") cleaner := clusters.NewCleaner(env.Cluster()) t.Cleanup(func() { + t.Helper() + + t.Log("performing test cleanup") ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5) defer cancel() assert.NoError(t, cleaner.Cleanup(ctx))