Skip to content

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

Open

Description

@soupdiver

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

Activity

  1. anderssonw commented on Apr 20, 2023

    @anderssonw

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

  2. emmajiafan commented on Apr 25, 2023

    @emmajiafan
    Contributor

    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".

  3. soupdiver commented on Apr 25, 2023

    @soupdiver
    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.

  4. emmajiafan commented on Apr 25, 2023

    @emmajiafan
    Contributor

    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)
    }
    
  5. emmajiafan commented on Apr 27, 2023

    @emmajiafan
    Contributor

    Here is the fix: https://github.com/kubernetes/client-go/issues/1245#issuecomment-1523434471 . But the latest controller-runtime release (0.14.6) doesn't contain the fix PR.

  6. added a commit that references this issue on Apr 28, 2023
  7. varshaprasad96 commented on May 8, 2023

    @varshaprasad96
    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.

  8. varshaprasad96 commented on May 8, 2023

    @varshaprasad96
    Member

    Mentioning the meta issue here to track: #6381

  9. varshaprasad96 commented on May 8, 2023

    @varshaprasad96
    Member

    Moving this backlog till then.

  10. added this to the Backlog milestone on May 8, 2023
  11. openshift-bot commented on Aug 7, 2023

    @openshift-bot

    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

  12. 7 remaining items

  13. skhaz commented on Oct 7, 2023

    @skhaz

    This auto closing issues are not great.

  14. skhaz commented on Oct 7, 2023

    @skhaz

    /reopen

  15. openshift-ci commented on Oct 7, 2023

    @openshift-ci

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

    Details

    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.

  16. skhaz commented on Oct 7, 2023

    @skhaz

    Great.

  17. everettraven commented on Oct 9, 2023

    @everettraven
    Contributor

    /reopen

  18. everettraven commented on Oct 9, 2023

    @everettraven
    Contributor

    /lifecycle frozen

  19. added
    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.
    and removed
    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.
    on Oct 9, 2023
  20. dvasilen commented on Mar 1, 2024

    @dvasilen

    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
    
  21. caozhuozi commented on Mar 16, 2025

    @caozhuozi

    @dvasilen it you keep using an older version of a software. you would never get things fixed. Fixes are always in newer version.

    See here: https://github.com/kubernetes/client-go/issues/1245#issuecomment-1523434471

    Basically, there's a subtle balance between the controller-runtime version and the k8s.io/* module versions to ensure everything works smoothly.

  22. caozhuozi commented on Mar 16, 2025

    @caozhuozi

    I think the issue can be closed.

    @varshaprasad96 @joelanford

  23. dvasilen commented on Mar 16, 2025

    @dvasilen

    @caozhuozi

    @dvasilen it you keep using an older version of a software. you would never get things fixed. Fixes are always in newer version.
    Basically, there's a subtle balance between the controller-runtime version and the k8s.io/* module versions to ensure everything works smoothly.

    Is there a deterministic approach to mapping the controller runtime version to the k8s.io/* module versions?
    If the balance is so subtle, would it make sense to release the matching versions to avoid the guessing game?

  24. caozhuozi commented on Mar 17, 2025

    @caozhuozi

    @dvasilen
    t’s better to use the same k8s.io/* version that the controller-runtime itself uses, as this is the safest approach. Using a different k8s.io/* version could potentially lead to issues.

    For example, if I use controller-runtime with the v0.2.0.3 tag, I should check which k8s.io/* version it relies on.
    https://github.com/kubernetes-sigs/controller-runtime/blob/v0.20.3/go.mod#L26-L28

  25. added a commit that references this issue on Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    language/goIssue is related to a Go operator projectlifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.triage/supportIndicates an issue that is a support question.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions