🐛 Add cross-version compatibility with client-go 1.27#2223
🐛 Add cross-version compatibility with client-go 1.27#2223k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
Conversation
|
Skipping CI for Draft Pull Request. |
| } | ||
| } | ||
| } | ||
| return true |
There was a problem hiding this comment.
seems like this will give a problematic answer with the old client?
There was a problem hiding this comment.
I would expect an old client can never call this since they would see a type ResourceEventHandlerRegistration interface{} as the return type. Of course they could attempt to type-cast that and would always get true, but that seems pretty obscure?
| return nil, err | ||
| } | ||
| handles[ns] = registration | ||
| handles.handles[ns] = registration |
There was a problem hiding this comment.
won't the multiple informers collide and overwrite the prior one's handle?
There was a problem hiding this comment.
wait, there's a different informer per namespace? ok nvm, sorry.
| } | ||
|
|
||
| func (e eventHandlerWrapper) OnAdd(obj interface{}) { | ||
| if m, ok := e.handler.(modernResourceEventHandler); ok { |
There was a problem hiding this comment.
This remind me of the http handlerfunc tech in the std library.
|
LGTM but I'm not a reviewer here :) |
|
/assign @alvaroaleman |
| // eventHandlerWrapper wraps a ResourceEventHandler in a manner that is compatible with client-go 1.27+ and older. | ||
| // The interface was changed in these versions. | ||
| type eventHandlerWrapper struct { | ||
| handler any |
There was a problem hiding this comment.
Can we use generics to type this to one of the two interfaces?
There was a problem hiding this comment.
I don't think so, or at least do not know how to. See golang/go#49054
|
|
||
| // HasSynced asserts that the handler has been called for the full initial state of the informer. | ||
| // This uses syncer to be compatible between client-go 1.27+ and older versions when the interface changed. | ||
| func (h handlerRegistration) HasSynced() bool { |
There was a problem hiding this comment.
I think I am blind, where do we call this?
There was a problem hiding this comment.
We don't call this, if allows the interface to be implemented on 0.27
There was a problem hiding this comment.
Since they added this function
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, howardjohn The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Ref fix: kubernetes-sigs/controller-runtime#2223 vendor/sigs.k8s.io/controller-runtime/pkg/cache/multi_namespace_cache.go:308:9: cannot use handles (variable of type map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration) as "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration value in return statement: map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced) vendor/sigs.k8s.io/controller-runtime/pkg/cache/multi_namespace_cache.go:321:9: cannot use handles (variable of type map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration) as "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration value in return statement: map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced) vendor/sigs.k8s.io/controller-runtime/pkg/cache/multi_namespace_cache.go:326:17: impossible type assertion: h.(map[string]toolscache.ResourceEventHandlerRegistration) map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced) make: *** [vendor/github.com/openshift/build-machinery-go/make/targets/golang/build.mk:16: build] Error 1 Signed-off-by: Flavio Fernandes <flaviof@redhat.com>
go get sigs.k8s.io/controller-runtime@v0.15.0-alpha.1 go mod tidy go mod vendor Reference fix: kubernetes-sigs/controller-runtime#2223 to address the following build issue: vendor/sigs.k8s.io/controller-runtime/pkg/cache/multi_namespace_cache.go:308:9: cannot use handles (variable of type map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration) as "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration value in return statement: map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced) vendor/sigs.k8s.io/controller-runtime/pkg/cache/multi_namespace_cache.go:321:9: cannot use handles (variable of type map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration) as "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration value in return statement: map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced) vendor/sigs.k8s.io/controller-runtime/pkg/cache/multi_namespace_cache.go:326:17: impossible type assertion: h.(map[string]toolscache.ResourceEventHandlerRegistration) map[string]"k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced) make: *** [vendor/github.com/openshift/build-machinery-go/make/targets/golang/build.mk:16: build] Error 1 Signed-off-by: Flavio Fernandes <flaviof@redhat.com>
Updating k8s libs to v1.27.1 requires updating sigs.k8s.io/controller-runtime to an unreleased version with kubernetes-sigs/controller-runtime#2223 in place. This in turn requires some additional adjustments to changed APIs in the controller-runtime, mainly in operator/pkg/gateway-api. The service.kubernetes.io/topology-aware-hints annotation got deprecated with k8s 1.27 in favor of service.kubernetes.io/topology-mode (see kubernetes/kubernetes#116522). This change keeps support for the deprecated annotation. Support for the new annotation will be added in a successive commit. Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Updating k8s libs to v1.27.2 requires updating sigs.k8s.io/controller-runtime to the 0.15 version with kubernetes-sigs/controller-runtime#2223 in place. This in turn requires some additional adjustments to changed APIs in the controller-runtime, mainly in operator/pkg/gateway-api. Specifically, around request methods and testing. The service.kubernetes.io/topology-aware-hints annotation got deprecated with k8s 1.27 in favor of service.kubernetes.io/topology-mode (see kubernetes/kubernetes#116522). This change keeps support for the deprecated annotation. Support for the new annotation will be added in a successive commit. Signed-off-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Updating k8s libs to v1.27.2 requires updating sigs.k8s.io/controller-runtime to the 0.15 version with kubernetes-sigs/controller-runtime#2223 in place. This in turn requires some additional adjustments to changed APIs in the controller-runtime, mainly in operator/pkg/gateway-api. Specifically, around request methods and testing. The service.kubernetes.io/topology-aware-hints annotation got deprecated with k8s 1.27 in favor of service.kubernetes.io/topology-mode (see kubernetes/kubernetes#116522). This change keeps support for the deprecated annotation. Support for the new annotation will be added in a successive commit. Signed-off-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Updating k8s libs to v1.27.2 requires updating sigs.k8s.io/controller-runtime to the 0.15 version with kubernetes-sigs/controller-runtime#2223 in place. This in turn requires some additional adjustments to changed APIs in the controller-runtime, mainly in operator/pkg/gateway-api. Specifically, around request methods and testing. The service.kubernetes.io/topology-aware-hints annotation got deprecated with k8s 1.27 in favor of service.kubernetes.io/topology-mode (see kubernetes/kubernetes#116522). This change keeps support for the deprecated annotation. Support for the new annotation will be added in a successive commit. Signed-off-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Updating k8s libs to v1.27.2 requires updating sigs.k8s.io/controller-runtime to the 0.15 version with kubernetes-sigs/controller-runtime#2223 in place. This in turn requires some additional adjustments to changed APIs in the controller-runtime, mainly in operator/pkg/gateway-api. Specifically, around request methods and testing. The service.kubernetes.io/topology-aware-hints annotation got deprecated with k8s 1.27 in favor of service.kubernetes.io/topology-mode (see kubernetes/kubernetes#116522). This change keeps support for the deprecated annotation. Support for the new annotation will be added in a successive commit. Signed-off-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Updating k8s libs to v1.27.2 requires updating sigs.k8s.io/controller-runtime to the 0.15 version with kubernetes-sigs/controller-runtime#2223 in place. This in turn requires some additional adjustments to changed APIs in the controller-runtime, mainly in operator/pkg/gateway-api. Specifically, around request methods and testing. The service.kubernetes.io/topology-aware-hints annotation got deprecated with k8s 1.27 in favor of service.kubernetes.io/topology-mode (see kubernetes/kubernetes#116522). This change keeps support for the deprecated annotation. Support for the new annotation will be added in a successive commit. Signed-off-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Updating k8s libs to v1.27.2 requires updating sigs.k8s.io/controller-runtime to the 0.15 version with kubernetes-sigs/controller-runtime#2223 in place. This in turn requires some additional adjustments to changed APIs in the controller-runtime, mainly in operator/pkg/gateway-api. Specifically, around request methods and testing. The service.kubernetes.io/topology-aware-hints annotation got deprecated with k8s 1.27 in favor of service.kubernetes.io/topology-mode (see kubernetes/kubernetes#116522). This change keeps support for the deprecated annotation. Support for the new annotation will be added in a successive commit. Signed-off-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Updating k8s libs to v1.27.2 requires updating sigs.k8s.io/controller-runtime to the 0.15 version with kubernetes-sigs/controller-runtime#2223 in place. This in turn requires some additional adjustments to changed APIs in the controller-runtime, mainly in operator/pkg/gateway-api. Specifically, around request methods and testing. The service.kubernetes.io/topology-aware-hints annotation got deprecated with k8s 1.27 in favor of service.kubernetes.io/topology-mode (see kubernetes/kubernetes#116522). This change keeps support for the deprecated annotation. Support for the new annotation will be added in a successive commit. Signed-off-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Fixes #2222
I have manually verified this compiles with client-go 1.26 and 1.27, but I am not sure how to get test coverage of this; likely we will not be able to.