-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Add cross-version compatibility with client-go 1.27 #2223
Conversation
Skipping CI for Draft Pull Request. |
} | ||
} | ||
} | ||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this will give a problematic answer with the old client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, gotcha
for ns, informer := range i.namespaceToInformer { | ||
registration, err := informer.AddEventHandler(handler) | ||
if err != nil { | ||
return nil, err | ||
} | ||
handles[ns] = registration | ||
handles.handles[ns] = registration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't the multiple informers collide and overwrite the prior one's handle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clever, lol
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use generics to type this to one of the two interfaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I am blind, where do we call this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't call this, if allows the interface to be implemented on 0.27
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Needs 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 <[email protected]>
go get sigs.k8s.io/[email protected] 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 <[email protected]>
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 <[email protected]>
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 <[email protected]> Signed-off-by: Nate Sweet <[email protected]>
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 <[email protected]> Signed-off-by: Nate Sweet <[email protected]>
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 <[email protected]> Signed-off-by: Nate Sweet <[email protected]>
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 <[email protected]> Signed-off-by: Nate Sweet <[email protected]>
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 <[email protected]> Signed-off-by: Nate Sweet <[email protected]>
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 <[email protected]> Signed-off-by: Nate Sweet <[email protected]>
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 <[email protected]> Signed-off-by: Nate Sweet <[email protected]>
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.