From 3206ab8d3f93b22061edc7c140e42b47b24c51c7 Mon Sep 17 00:00:00 2001 From: Todd Short Date: Thu, 11 Sep 2025 17:35:16 -0400 Subject: [PATCH] Use old and new pod selectors during kustomize-to-helm transition Downstream e2es are failing because the old selectors are still being used. --- test/e2e/metrics_test.go | 26 +++++++++++++++----------- test/e2e/network_policy_test.go | 7 +++++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/test/e2e/metrics_test.go b/test/e2e/metrics_test.go index 80b97d98b..54ff41201 100644 --- a/test/e2e/metrics_test.go +++ b/test/e2e/metrics_test.go @@ -32,7 +32,7 @@ import ( func TestOperatorControllerMetricsExportedEndpoint(t *testing.T) { client := utils.FindK8sClient(t) curlNamespace := createRandomNamespace(t, client) - componentNamespace := getComponentNamespace(t, client, "app.kubernetes.io/name=operator-controller") + componentNamespace := getComponentNamespace(t, client, operatorManagerSelector) metricsURL := fmt.Sprintf("https://operator-controller-service.%s.svc.cluster.local:8443/metrics", componentNamespace) config := NewMetricsTestConfig( @@ -52,7 +52,7 @@ func TestOperatorControllerMetricsExportedEndpoint(t *testing.T) { func TestCatalogdMetricsExportedEndpoint(t *testing.T) { client := utils.FindK8sClient(t) curlNamespace := createRandomNamespace(t, client) - componentNamespace := getComponentNamespace(t, client, "app.kubernetes.io/name=catalogd") + componentNamespace := getComponentNamespace(t, client, catalogdManagerSelector) metricsURL := fmt.Sprintf("https://catalogd-service.%s.svc.cluster.local:7443/metrics", componentNamespace) config := NewMetricsTestConfig( @@ -231,16 +231,20 @@ func createRandomNamespace(t *testing.T, client string) string { } // getComponentNamespace returns the namespace where operator-controller or catalogd is running -func getComponentNamespace(t *testing.T, client, selector string) string { - cmd := exec.Command(client, "get", "pods", "--all-namespaces", "--selector="+selector, "--output=jsonpath={.items[0].metadata.namespace}") - output, err := cmd.CombinedOutput() - require.NoError(t, err, "Error determining namespace: %s", string(output)) - - namespace := string(bytes.TrimSpace(output)) - if namespace == "" { - t.Fatal("No namespace found for selector " + selector) +func getComponentNamespace(t *testing.T, client string, selectors []string) string { + for _, selector := range selectors { + cmd := exec.Command(client, "get", "pods", "--all-namespaces", "--selector="+selector, "--output=jsonpath={.items[0].metadata.namespace}") + output, err := cmd.CombinedOutput() + if err != nil { + continue + } + namespace := string(bytes.TrimSpace(output)) + if namespace != "" { + return namespace + } } - return namespace + t.Fatalf("No namespace found for selectors: %v", selectors) + return "" } func stdoutAndCombined(cmd *exec.Cmd) ([]byte, []byte, error) { diff --git a/test/e2e/network_policy_test.go b/test/e2e/network_policy_test.go index 9e0dc6e6c..ad35e72cb 100644 --- a/test/e2e/network_policy_test.go +++ b/test/e2e/network_policy_test.go @@ -20,14 +20,17 @@ import ( const ( minJustificationLength = 40 - catalogdManagerSelector = "app.kubernetes.io/name=catalogd" - operatorManagerSelector = "app.kubernetes.io/name=operator-controller" catalogdMetricsPort = 7443 catalogdWebhookPort = 9443 catalogServerPort = 8443 operatorControllerMetricsPort = 8443 ) +var ( + catalogdManagerSelector = []string{"app.kubernetes.io/name=catalogd", "control-plane=catalogd-controller-manager"} + operatorManagerSelector = []string{"app.kubernetes.io/name=operator-controller", "control-plane=operator-controller-controller-manager"} +) + type portWithJustification struct { port []networkingv1.NetworkPolicyPort justification string