operator-sdk: Get error go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced)
Bug Report
What did you do?
make run
What did you expect to see?
the operator be built and run
What did you see instead? Under which circumstances?
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
Environment
Operator type:
/language go
Kubernetes cluster type:
k3s
$ operator-sdk version
operator-sdk version: "v1.28.0", commit: "484013d1865c35df2bc5dfea0ab6ea6b434adefa", kubernetes version: "1.26.0", go version: "go1.19.6", GOOS: "linux", GOARCH: "amd64"
$ go version
(if language is Go)
go version go1.20.3 linux/amd64
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.3+k3s1", GitCommit:"01ea3ff27be0b04f945179171cec5a8e11a14f7b", GitTreeState:"clean", BuildDate:"2023-03-27T22:23:17Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.3+k3s1", GitCommit:"01ea3ff27be0b04f945179171cec5a8e11a14f7b", GitTreeState:"clean", BuildDate:"2023-03-27T22:23:17Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
Potential fix
Downgrade dependencies to
k8s.io/api v0.26.4
k8s.io/apimachinery v0.26.4
k8s.io/client-go v0.26.4
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 31
- Comments: 18 (8 by maintainers)
Commits related to this issue
- deps: Bump opentelemetry go get -u github.com/go-logr/logr go.opentelemetry.io/otel go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc go.opentelemetry.io/otel/metric go.opentelemetry.... — committed to viccuad/kubewarden-controller by viccuad a year ago
- Fix functional test dependencies - go get github.com/helmfile/helmfile && go mod tidy - manually pin back to 0.26 from 0.27 to avoid build errors: * k8s.io/api * k8s.io/apimachinery * k8... — committed to dominodatalab/hephaestus by ddl-ebrown a year ago
- Fix functional test dependencies - go get github.com/helmfile/helmfile && go mod tidy - manually pin back to 0.26 from 0.27 to avoid build errors: * k8s.io/api * k8s.io/apimachinery * k8... — committed to dominodatalab/hephaestus by ddl-ebrown a year ago
This happened with us as well after the recent update to client-go >= 0.27
/reopen
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