kubernetes / client-go

Go client for Kubernetes.
Apache License 2.0
8.99k stars 2.94k forks source link

k8s.io/client-go/tools/cache .ResourceEventHandlerRegistration (missing method HasSynced) #1245

Closed emmajiafan closed 1 year ago

emmajiafan commented 1 year ago

https://github.com/operator-framework/operator-sdk/issues/6396

go fmt ./...
go vet ./...
# sigs.k8s.io/controller-runtime/pkg/cache
../../../go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/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)
../../../go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/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)
../../../go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/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: *** [Makefile:110: vet] Error 1

.ResourceEventHandlerRegistration does not implement "k8s.io/client-go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced)

This problem occurs after update the client-go to " >= v0.27.0". The type ResourceEventHandlerRegistration is added to client-go from v0.26.0. But it is different with 0.27.0.

0.26.0: type ResourceEventHandlerRegistration interface{} 0.26.4 type ResourceEventHandlerRegistration interface{} 0.27.0

type ResourceEventHandlerRegistration interface {
    // HasSynced reports if both the parent has synced and all pre-sync
    // events have been delivered.
    HasSynced() [bool](https://pkg.go.dev/builtin#bool)
}
emmajiafan commented 1 year ago

meet the same problem here: https://github.com/openshift/ingress-node-firewall/pull/334

liggitt commented 1 year ago

I think you need to update controller-runtime to a version that includes https://github.com/kubernetes-sigs/controller-runtime/pull/2223 before updating to client-go 0.27.0 (which may mean controller-runtime needs to tag a version that includes that)

emmajiafan commented 1 year ago

@liggitt Thank you so much!