Skip to content
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

Get error go/tools/cache".ResourceEventHandlerRegistration (missing method HasSynced) #6396

Open
soupdiver opened this issue Apr 17, 2023 · 19 comments
Labels
language/go Issue is related to a Go operator project lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. triage/support Indicates an issue that is a support question.
Milestone

Comments

@soupdiver
Copy link

soupdiver commented Apr 17, 2023

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
@openshift-ci openshift-ci bot added the language/go Issue is related to a Go operator project label Apr 17, 2023
@kensipe kensipe added the triage/support Indicates an issue that is a support question. label Apr 17, 2023
@anderssonw
Copy link

This happened with us as well after the recent update to client-go >= 0.27

@emmajiafan
Copy link
Contributor

emmajiafan commented Apr 25, 2023

The type ResourceEventHandlerRegistration is added to client-go from v0.26.0. But the v0.27.0 updates the code. So the problem occurs after update the client-go to " >= v0.27.0".

@soupdiver
Copy link
Author

The type ResourceEventHandlerRegistration is added to client-go from v0.26.0. So the problem occurs after update the client-go to " >= v0.26.0".

I don't think that's actually true or do you mean >= v0.27.0?
Because downgrading the deps from 0.27 to 0.26 actually fixed the issue for me.

@emmajiafan
Copy link
Contributor

emmajiafan commented Apr 25, 2023

The type ResourceEventHandlerRegistration is added to client-go from v0.26.0. So the problem occurs after update the client-go to " >= v0.26.0".

I don't think that's actually true or do you mean >= v0.27.0? Because downgrading the deps from 0.27 to 0.26 actually fixed the issue for me.

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
Copy link
Contributor

Here is the fix: kubernetes/client-go#1245 (comment) . But the latest controller-runtime release (0.14.6) doesn't contain the fix PR.

viccuad added a commit to viccuad/kubewarden-controller that referenced this issue Apr 28, 2023
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.io/otel/sdk/metric
go mod tidy

Can't bump to client-go v0.27.1:
operator-framework/operator-sdk#6396

Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
@varshaprasad96
Copy link
Member

We have still not made necessary changes in SDK to adapt to k8s 1.27 release (

k8s.io/client-go v0.26.2
), its still pinned to 1.26. Before moving to 1.27 we would need a string of dependent repos to update themselves (Kubebuilder, controller-runtime, controller-tools) etc. I'd suggest to not upgrade your dependencies to 1.27 yet, until we have a SDK version that supports the same.

@varshaprasad96
Copy link
Member

Mentioning the meta issue here to track: #6381

@varshaprasad96
Copy link
Member

Moving this backlog till then.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 6, 2023
@openshift-bot
Copy link

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci
Copy link

openshift-ci bot commented Oct 7, 2023

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot closed this as completed Oct 7, 2023
@skhaz
Copy link

skhaz commented Oct 7, 2023

This auto closing issues are not great.

@skhaz
Copy link

skhaz commented Oct 7, 2023

/reopen

@openshift-ci
Copy link

openshift-ci bot commented Oct 7, 2023

@skhaz: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@skhaz
Copy link

skhaz commented Oct 7, 2023

Great.

@everettraven
Copy link
Contributor

/reopen

@everettraven everettraven reopened this Oct 9, 2023
@everettraven
Copy link
Contributor

/lifecycle frozen

@openshift-ci openshift-ci bot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Oct 9, 2023
@dvasilen
Copy link

dvasilen commented Mar 1, 2024

Approaching one year anniversary for this issue. Still not fixed.

# sigs.k8s.io/controller-runtime/pkg/cache

../../../../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)

../../../../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)

../../../../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:298: go-build] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/go Issue is related to a Go operator project lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. triage/support Indicates an issue that is a support question.
Projects
None yet
Development

No branches or pull requests

9 participants