diff --git a/go.mod b/go.mod index dd97fc81f160..a5f1e565cff1 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/openshift/build-machinery-go v0.0.0-20240613134303-8359781da660 github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f github.com/openshift/cluster-network-operator v0.0.0-20240708200319-1cd8678b38fb - github.com/openshift/library-go v0.0.0-20241010221945-bd9dfdd95f7b + github.com/openshift/library-go v0.0.0-20241015130640-f9ecd211c68b github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.20.2 diff --git a/go.sum b/go.sum index b0ceb0c97c4a..d95c28c6211b 100644 --- a/go.sum +++ b/go.sum @@ -720,8 +720,8 @@ github.com/openshift/kubernetes/staging/src/k8s.io/pod-security-admission v0.0.0 github.com/openshift/kubernetes/staging/src/k8s.io/pod-security-admission v0.0.0-20241002124647-1892e4deb967/go.mod h1:cmVAeH6nq/BICRHjs7alZYCGXGFzZapRDIoFsXXJSsw= github.com/openshift/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20241002124647-1892e4deb967 h1:85E8kHrVptr6SeoFHxU/wplZweb+likneYpI4jdCBb4= github.com/openshift/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20241002124647-1892e4deb967/go.mod h1:mtBTrqylZ7Lv0pmB5XpbDK1QCiovEdaUNo/u/vaK2Lo= -github.com/openshift/library-go v0.0.0-20241010221945-bd9dfdd95f7b h1:L2bj24+Fsoq8KzHTwoiYNW+K18O5MCsxThQhkvC9+r0= -github.com/openshift/library-go v0.0.0-20241010221945-bd9dfdd95f7b/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0= +github.com/openshift/library-go v0.0.0-20241015130640-f9ecd211c68b h1:NfHXfIpgWLoxhxOf9Ci/bm1xVp6T9RBgK1MfbVVzAvw= +github.com/openshift/library-go v0.0.0-20241015130640-f9ecd211c68b/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0= github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20240806135314-3946b2b7b2a8 h1:HJvLw9nNfoqCs16h505eP8E1kVmq6KNdzGm5csPlYsQ= github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20240806135314-3946b2b7b2a8/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= diff --git a/test/extended/apiserver/patch.go b/test/extended/apiserver/patch.go index 46035b44c09d..bdf8e5d2df0f 100644 --- a/test/extended/apiserver/patch.go +++ b/test/extended/apiserver/patch.go @@ -43,6 +43,19 @@ var _ = g.Describe("[sig-api-machinery] JSON Patch [apigroup:operator.openshift. {NodeName: "master-1"}, })) }) + g.It("should delete multiple entries from an array when multiple test precondition provided", func() { + g.By("Creating KubeAPIServerOperator CR for the test") + resourceClient := createResourceClient(oc.AdminConfig(), gvr) + kasOperator := createWellKnownKubeAPIServerOperatorResource(ctx, resourceClient) + + g.By("Applying a JSON Patch to remove a node status at index 0 and 1") + jsonPatch := jsonpatch.New(). + WithRemove("/status/nodeStatuses/0", jsonpatch.NewTestCondition("/status/nodeStatuses/0/nodeName", "master-1")). + WithRemove("/status/nodeStatuses/0", jsonpatch.NewTestCondition("/status/nodeStatuses/0/nodeName", "master-2")) + kasOperator, err := applyJSONPatch(ctx, kasOperator.Name, jsonPatch, resourceClient) + o.Expect(err).NotTo(o.HaveOccurred()) + o.Expect(kasOperator.Status.NodeStatuses).To(o.HaveLen(0)) + }) g.It("should error when the test precondition provided doesn't match", func() { g.By("Creating KubeAPIServerOperator CR for the test") resourceClient := createResourceClient(oc.AdminConfig(), gvr) diff --git a/test/extended/util/annotate/generated/zz_generated.annotations.go b/test/extended/util/annotate/generated/zz_generated.annotations.go index 5b477d26b0f1..68fe8bce25fa 100644 --- a/test/extended/util/annotate/generated/zz_generated.annotations.go +++ b/test/extended/util/annotate/generated/zz_generated.annotations.go @@ -31,6 +31,8 @@ var Annotations = map[string]string{ "[sig-api-machinery] JSON Patch [apigroup:operator.openshift.io] should delete an entry from an array with multiple field owners": " [Suite:openshift/conformance/parallel]", + "[sig-api-machinery] JSON Patch [apigroup:operator.openshift.io] should delete multiple entries from an array when multiple test precondition provided": " [Suite:openshift/conformance/parallel]", + "[sig-api-machinery] JSON Patch [apigroup:operator.openshift.io] should error when the test precondition provided doesn't match": " [Suite:openshift/conformance/parallel]", "[sig-api-machinery][Feature:APIServer] TestTLSDefaults": " [Suite:openshift/conformance/parallel]", diff --git a/vendor/github.com/openshift/library-go/pkg/apiserver/jsonpatch/jsonpatch.go b/vendor/github.com/openshift/library-go/pkg/apiserver/jsonpatch/jsonpatch.go index 4e4ab1d74d59..50a67cd7820a 100644 --- a/vendor/github.com/openshift/library-go/pkg/apiserver/jsonpatch/jsonpatch.go +++ b/vendor/github.com/openshift/library-go/pkg/apiserver/jsonpatch/jsonpatch.go @@ -48,10 +48,6 @@ func (p *PatchSet) addOperation(op, path string, value interface{}) { Path: path, Value: value, } - if op == patchTestOperation { - p.patches = append([]PatchOperation{patch}, p.patches...) - return - } p.patches = append(p.patches, patch) } diff --git a/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/informers.go b/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/informers.go index 1dd17e7590b5..cd31031242ca 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/informers.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/v1helpers/informers.go @@ -2,6 +2,7 @@ package v1helpers import ( "fmt" + "reflect" "time" corev1 "k8s.io/api/core/v1" @@ -18,6 +19,10 @@ type KubeInformersForNamespaces interface { InformersFor(namespace string) informers.SharedInformerFactory Namespaces() sets.Set[string] + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. + WaitForCacheSync(stopCh <-chan struct{}) map[string]map[reflect.Type]bool + ConfigMapLister() corev1listers.ConfigMapLister SecretLister() corev1listers.SecretLister @@ -42,6 +47,16 @@ func NewKubeInformersForNamespaces(kubeClient kubernetes.Interface, namespaces . type kubeInformersForNamespaces map[string]informers.SharedInformerFactory +// WaitForCacheSync waits for all started informers' cache were synced. +func (i kubeInformersForNamespaces) WaitForCacheSync(stopCh <-chan struct{}) map[string]map[reflect.Type]bool { + ret := map[string]map[reflect.Type]bool{} + for namespace, informerFactory := range i { + ret[namespace] = informerFactory.WaitForCacheSync(stopCh) + } + + return ret +} + func (i kubeInformersForNamespaces) Start(stopCh <-chan struct{}) { for _, informer := range i { informer.Start(stopCh) diff --git a/vendor/modules.txt b/vendor/modules.txt index ad6c960ba718..15ce81b8c860 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1042,7 +1042,7 @@ github.com/openshift/client-go/user/listers/user/v1 # github.com/openshift/cluster-network-operator v0.0.0-20240708200319-1cd8678b38fb ## explicit; go 1.22.0 github.com/openshift/cluster-network-operator/pkg/names -# github.com/openshift/library-go v0.0.0-20241010221945-bd9dfdd95f7b +# github.com/openshift/library-go v0.0.0-20241015130640-f9ecd211c68b ## explicit; go 1.22.0 github.com/openshift/library-go/pkg/apiserver/admission/admissionrestconfig github.com/openshift/library-go/pkg/apiserver/admission/admissiontimeout