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

Undefined SwitchMetric Error with client-go 0.30.0 in Go Vet #2788

Closed
kkb0318 opened this issue Apr 18, 2024 · 9 comments
Closed

Undefined SwitchMetric Error with client-go 0.30.0 in Go Vet #2788

kkb0318 opened this issue Apr 18, 2024 · 9 comments

Comments

@kkb0318
Copy link

kkb0318 commented Apr 18, 2024

I recently updated to client-go version 0.30.0 while developing a Kubernetes controller using the Operator SDK. When running go vet ./... on my project, the following error occurred, suggesting an issue with the controller-runtime package:

❯ go vet ./...
# sigs.k8s.io/controller-runtime/pkg/metrics
/Users/kkb/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/metrics/leaderelection.go:26:71: undefined: leaderelection.SwitchMetric

Go Version

go version go1.22.2 darwin/amd64

OS

MacOS 14.4.1

@kkb0318 kkb0318 changed the title Undefined SwitchMetric Error with client-go 1.30.0 in Go Vet Undefined SwitchMetric Error with client-go 0.30.0 in Go Vet Apr 18, 2024
@sbueringer
Copy link
Member

sbueringer commented Apr 18, 2024

Controller-runtime v0.17.3 is using client-go 0.29.

Sometimes it's impossible for us to be compatible with multiple client-go versions at the same time. IIRC this is such a case.

So I think the only options are:

  • to stay on client-go 0.29 (for now)
  • to switch to controller-runtime main branch + client-go 0.30 (and eventually upgrade to v0.18)

@kkb0318
Copy link
Author

kkb0318 commented Apr 19, 2024

Thank you for the quick response and the clarification.

I appreciate the guidance on compatible versions. I wasn't aware that client-go had updated so recently.
I will wait to update until the controller-runtime is compatible with the newer client-go version.

Thanks again for your support!

@sbueringer
Copy link
Member

sbueringer commented Apr 19, 2024

You're welcome.

The general pattern at the moment is that we have a 1:1 mapping between controller-runtime and client-go (i.e. at least 1 controller-runtime release for every client-go release)

We try to stay as compatible as possible with other client-go versions but that is not always possible. It largely depends on if there are breaking changes in client-go and what these are (i.e. if they can be mitigated).

There is now also a PR in k/k: kubernetes/kubernetes#124372. Depending on the outcome it could be that client-go v0.30.1+ will be compatible with CR v0.17 again.

@rahulsb
Copy link

rahulsb commented Apr 23, 2024

I have upgraded my operator code to adopt K8s v0.30 this week and seeing this issue. When are we planning to release v0.18 with this adoption ?

@sbueringer
Copy link
Member

sbueringer commented Apr 23, 2024

Current plan was this week. Related Slack thread: https://kubernetes.slack.com/archives/C02MRBMN00Z/p1713510019996969

nit: I don't think this is a bug in controller-runtime, rather a breaking change in client-go

@rahulsb
Copy link

rahulsb commented Apr 23, 2024

Current plan was this week. Related Slack thread: https://kubernetes.slack.com/archives/C02MRBMN00Z/p1713510019996969

nit: I don't think this is a bug in controller-runtime, rather a breaking change in client-go

Thanks for actively working on this. Sorry, I have fixed my comments. Looking forward to the new release.

@rashedkvm
Copy link

Thank you for the quick fix and release.

@sbueringer
Copy link
Member

@alvaroaleman should we close this or wait if there's something that we should do after kubernetes/kubernetes#124372 merges?

I lean towards there's probably nothing we can do. But we can wait a bit and see what happens to the k/k PR. I suspect it might make client-go 0.30.x compatible with CR v0.17. But given that we don't have any testing I wouldn't try to make CR v0.18 compatible with client-go 0.29

@alvaroaleman
Copy link
Member

I lean towards there's probably nothing we can do. But we can wait a bit and see what happens to the k/k PR. I suspect it might make client-go 0.30.x compatible with CR v0.17. But given that we don't have any testing I wouldn't try to make CR v0.18 compatible with client-go 0.29

Yeah, realistically we have a 1:1 mapping between the two, as there is no testing for skew, we can not promise that it will work anyways.

dtthuynh added a commit to dtthuynh/clusterclaims-controller that referenced this issue Sep 5, 2024
- Upgraded to latest hive api from mce-2.7 branch
- Upgraded to go 1.22
- Changed code due to changes in the behaviour of runtime-controller library
- remove unncessary dependencies from go.mod

See related issues on changes for runtime-controller that needed to be addressed:
- kubernetes-sigs/controller-runtime#2788
- kubernetes-sigs/controller-runtime#1517
dtthuynh added a commit to dtthuynh/clusterclaims-controller that referenced this issue Sep 5, 2024
- Upgraded to latest hive api from mce-2.7 branch
- Upgraded to go 1.22
- Changed code due to changes in the behaviour of runtime-controller library
- remove unncessary dependencies from go.mod

See related issues on changes for runtime-controller that needed to be addressed:
- kubernetes-sigs/controller-runtime#2788
- kubernetes-sigs/controller-runtime#1517
dtthuynh added a commit to dtthuynh/clusterclaims-controller that referenced this issue Sep 5, 2024
- Upgraded to latest hive api from mce-2.7 branch
- Upgraded to go 1.22
- Changed code due to changes in the behaviour of runtime-controller library
- remove unncessary dependencies from go.mod

See related issues on changes for runtime-controller that needed to be addressed:
- kubernetes-sigs/controller-runtime#2788
- kubernetes-sigs/controller-runtime#1517

Signed-off-by: David Huynh <dhuynh@redhat.com>
openshift-merge-bot bot pushed a commit to stolostron/clusterclaims-controller that referenced this issue Sep 5, 2024
- Upgraded to latest hive api from mce-2.7 branch
- Upgraded to go 1.22
- Changed code due to changes in the behaviour of runtime-controller library
- remove unncessary dependencies from go.mod

See related issues on changes for runtime-controller that needed to be addressed:
- kubernetes-sigs/controller-runtime#2788
- kubernetes-sigs/controller-runtime#1517

Signed-off-by: David Huynh <dhuynh@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants