Skip to content

Commit 2bc51b3

Browse files
Merge pull request #30397 from Miciah/gatewayapicontroller-use-dynamic-client-for-olm
OCPBUGS-56281: gatewayapicontroller: Use dynamic client for OLM
2 parents 43159a2 + c5d2f04 commit 2bc51b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+50
-6366
lines changed

go.mod

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ require (
5959
github.com/onsi/gomega v1.37.0
6060
github.com/opencontainers/go-digest v1.0.0
6161
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250711173707-dc2a20e5a5f8
62-
github.com/openshift/api v3.9.0+incompatible
62+
github.com/openshift/api v0.0.0-20250710004639-926605d3338b
6363
github.com/openshift/apiserver-library-go v0.0.0-20250710132015-f0d44ef6e53b
6464
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
6565
github.com/openshift/client-go v0.0.0-20250710075018-396b36f983ee
6666
github.com/openshift/library-go v0.0.0-20250812160438-378de074fe7b
67-
github.com/operator-framework/operator-lifecycle-manager v0.30.1-0.20250114164243-1b6752ec65fa
6867
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20250118001652-a8b9c3c31417
6968
github.com/pborman/uuid v1.2.0
7069
github.com/pkg/errors v0.9.1
@@ -133,6 +132,7 @@ require (
133132
cloud.google.com/go/iam v1.5.2 // indirect
134133
cloud.google.com/go/monitoring v1.24.2 // indirect
135134
git.sr.ht/~sbinet/gg v0.5.0 // indirect
135+
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
136136
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
137137
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.0 // indirect
138138
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets v0.12.0 // indirect
@@ -196,6 +196,7 @@ require (
196196
github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect
197197
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
198198
github.com/fatih/camelcase v1.0.0 // indirect
199+
github.com/fatih/color v1.18.0 // indirect
199200
github.com/felixge/fgprof v0.9.4 // indirect
200201
github.com/felixge/httpsnoop v1.0.4 // indirect
201202
github.com/fsnotify/fsnotify v1.8.0 // indirect
@@ -310,7 +311,6 @@ require (
310311
github.com/opencontainers/runtime-spec v1.2.0 // indirect
311312
github.com/opencontainers/selinux v1.11.1 // indirect
312313
github.com/opentracing/opentracing-go v1.2.0 // indirect
313-
github.com/operator-framework/api v0.27.0 // indirect
314314
github.com/pelletier/go-toml v1.9.5 // indirect
315315
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
316316
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
@@ -441,6 +441,3 @@ replace (
441441
k8s.io/sample-cli-plugin => github.com/openshift/kubernetes/staging/src/k8s.io/sample-cli-plugin v0.0.0-20250906192346-6efb6a95323f
442442
k8s.io/sample-controller => github.com/openshift/kubernetes/staging/src/k8s.io/sample-controller v0.0.0-20250906192346-6efb6a95323f
443443
)
444-
445-
// github.com/operator-framework/operator-lifecycle-manager requires this import.
446-
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20250710004639-926605d3338b

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,10 +868,6 @@ github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20250416174521-4eb003743b54/go.mod
868868
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
869869
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
870870
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
871-
github.com/operator-framework/api v0.27.0 h1:OrVaGKZJvbZo58HTv2guz7aURkhVKYhFqZ/6VpifiXI=
872-
github.com/operator-framework/api v0.27.0/go.mod h1:lg2Xx+S8NQWGYlEOvFwQvH46E5EK5IrAIL7HWfAhciM=
873-
github.com/operator-framework/operator-lifecycle-manager v0.30.1-0.20250114164243-1b6752ec65fa h1:VzZn+vxGFprQPnaLVDgU5Wfu+2UHsQJh/xLwJw8rXkA=
874-
github.com/operator-framework/operator-lifecycle-manager v0.30.1-0.20250114164243-1b6752ec65fa/go.mod h1:kzt/wadHjn76OoJeuu7BFzJFRh780BSMYuWaSxk9HGA=
875871
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
876872
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20250118001652-a8b9c3c31417 h1:7k+dokKFfpICbkpX5TvvpFbKTFsl/6YQd46EpY2JNhc=
877873
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20250118001652-a8b9c3c31417/go.mod h1:9LxDV3rAHlGHAYtVrT62y/fqfIxc5RrDiYi9RVeD0gg=

test/extended/router/gatewayapicontroller.go

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ import (
1414

1515
configv1 "github.com/openshift/api/config/v1"
1616
operatoringressv1 "github.com/openshift/api/operatoringress/v1"
17-
operatorsv1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/typed/operators/v1"
1817

1918
exutil "github.com/openshift/origin/test/extended/util"
2019
corev1 "k8s.io/api/core/v1"
2120
apierrors "k8s.io/apimachinery/pkg/api/errors"
21+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
22+
"k8s.io/apimachinery/pkg/runtime/schema"
23+
"k8s.io/apimachinery/pkg/types"
2224
"k8s.io/apimachinery/pkg/util/intstr"
2325
e2e "k8s.io/kubernetes/test/e2e/framework"
2426
admissionapi "k8s.io/pod-security-admission/api"
@@ -160,17 +162,29 @@ var _ = g.Describe("[sig-network-edge][OCPFeatureGate:GatewayAPIController][Feat
160162

161163
g.By("Deleting the OSSM Operator resources")
162164

163-
operator, err := operatorsv1.NewForConfigOrDie(oc.AsAdmin().UserConfig()).Operators().Get(context.Background(), serviceMeshOperatorName, metav1.GetOptions{})
165+
gvr := schema.GroupVersionResource{
166+
Group: "operators.coreos.com",
167+
Version: "v1",
168+
Resource: "operators",
169+
}
170+
operator, err := oc.KubeFramework().DynamicClient.Resource(gvr).Get(context.Background(), serviceMeshOperatorName, metav1.GetOptions{})
164171
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to get Operator %q", serviceMeshOperatorName)
165172

173+
refs, ok, err := unstructured.NestedSlice(operator.Object, "status", "components", "refs")
174+
o.Expect(err).NotTo(o.HaveOccurred())
175+
o.Expect(ok).To(o.BeTrue(), "Failed to find status.components.refs in Operator %q", serviceMeshOperatorName)
166176
restmapper := oc.AsAdmin().RESTMapper()
167-
for _, ref := range operator.Status.Components.Refs {
177+
for _, ref := range refs {
178+
ref := extractObjectReference(ref.(map[string]any))
168179
mapping, err := restmapper.RESTMapping(ref.GroupVersionKind().GroupKind())
169180
o.Expect(err).NotTo(o.HaveOccurred())
170181

182+
e2e.Logf("Deleting %s %s/%s...", ref.Kind, ref.Namespace, ref.Name)
171183
err = oc.KubeFramework().DynamicClient.Resource(mapping.Resource).Namespace(ref.Namespace).Delete(context.Background(), ref.Name, metav1.DeleteOptions{})
172184
o.Expect(err).Should(o.Or(o.Not(o.HaveOccurred()), o.MatchError(apierrors.IsNotFound, "IsNotFound")), "Failed to delete %s %q: %v", ref.GroupVersionKind().Kind, ref.Name, err)
173185
}
186+
187+
o.Expect(oc.AsAdmin().WithoutNamespace().Run("delete").Args("operators", serviceMeshOperatorName).Execute()).Should(o.Succeed())
174188
}
175189
})
176190

@@ -850,3 +864,28 @@ func checkAllTestsDone(oc *exutil.CLI) bool {
850864

851865
return true
852866
}
867+
868+
// getNestedString returns a string value of a nested field value of an
869+
// unstructured.Unstructured object. If the named field is of a non-string
870+
// type, getNestedString returns the empty string.
871+
func getNestedString(obj map[string]any, field string) string {
872+
val, found, err := unstructured.NestedString(obj, field)
873+
if !found || err != nil {
874+
return ""
875+
}
876+
return val
877+
}
878+
879+
// extractObjectReference returns a ObjectReference value of a nested field
880+
// value of an unstructured.Unstructured object.
881+
func extractObjectReference(v map[string]any) corev1.ObjectReference {
882+
return corev1.ObjectReference{
883+
Kind: getNestedString(v, "kind"),
884+
Namespace: getNestedString(v, "namespace"),
885+
Name: getNestedString(v, "name"),
886+
UID: types.UID(getNestedString(v, "uid")),
887+
APIVersion: getNestedString(v, "apiVersion"),
888+
ResourceVersion: getNestedString(v, "resourceVersion"),
889+
FieldPath: getNestedString(v, "fieldPath"),
890+
}
891+
}

vendor/github.com/operator-framework/api/LICENSE

Lines changed: 0 additions & 201 deletions
This file was deleted.

0 commit comments

Comments
 (0)