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

'unknown revision v0.0.0' errors caused by the 'k8s.io/kubernetes' dependency #2490

Open
ProbstDJakob opened this issue Dec 4, 2023 · 8 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@ProbstDJakob
Copy link
Contributor

Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug

What happened:
When executing go list -m all multiple dependencies can not be resolved due to invalid versions. This command (with some additional flags) is used by JetBrain's GoLand to sync the dependencies and since the command fails, the IDE is not capable to resolve any dependency which results in a huge pile of errors per file.

What you expected to happen:
That the command completes successfully and prints out all modules.

How to reproduce it:
Clone the repository and execute the command go list -m all. This will produce the following errors:

go: k8s.io/cluster-bootstrap@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/dynamic-resource-allocation@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/endpointslice@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/kube-aggregator@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/kube-controller-manager@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/kube-proxy@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/kube-scheduler@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/legacy-cloud-providers@v0.0.0: invalid version: unknown revision v0.0.0
go: k8s.io/sample-apiserver@v0.0.0: invalid version: unknown revision v0.0.0

Anything else we need to know?:
The problem seems to be the dependency k8s.io/kubernetes. As described here (and discussed in more detail here) k8s.io/kubernetes should not be used as a dependency. Removing the dependency from the go.mod and executing the command again will result in a proper list of the modules (and the IDE is able to resolve the dependencies), but building the code will fail since some files depend on k8s.io/kubernetes (mostly tests).
This issue may be related to #1633 and #347

Environment:

  • openstack-cloud-controller-manager(or other related binary) version:
  • OpenStack version:
  • Others:
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 4, 2023
@kayrus
Copy link
Contributor

kayrus commented Dec 5, 2023

running a go mod tidy brings the k8s.io/kubernetes dependency back, since OCCM test code relies on the k8s.io/kubernetes/test/e2e/... packages.
Why do you need to run a go list -m all command?

UPD: as for the regular code, we initialize k8s feature gates in the OCCM cmd:

_ "k8s.io/kubernetes/pkg/features" // add the kubernetes feature gates

https://github.com/kubernetes/kubernetes/blob/55f2bc10435160619d1ece8de49a1c0f8fcdf276/pkg/features/kube_features.go#L980-L982

@ProbstDJakob
Copy link
Contributor Author

I do not need the command, but as I wrote JetBrain's GoLand executes the command to resolve the dependencies. Since the command fails, the error indicators on the right within a source file look like the red carpet since the IDE can not resolve the imports.

I know where the the k8s.io/kubernetes dependency is used, but I do not know how to replace it since the list provided at the kubernetes repo does not include any of the imported modules as far as I can tell (I usually do not program in go and I am new to the source code of k8s).

@dulek
Copy link
Contributor

dulek commented Dec 6, 2023

running a go mod tidy brings the k8s.io/kubernetes dependency back, since OCCM test code relies on the k8s.io/kubernetes/test/e2e/... packages. Why do you need to run a go list -m all command?

This command is automatically issued by Golang each time repo gets updated, I actually suffer from this too, just was ignoring this. @ProbstDJakob, you can safely ignore it BTW, I assure you. Do go mod vendor manually instead.

So seems like in order to use the K8s testing framework you need to indeed import whole k8s.io/kubernetes. Azure simply doesn't use the framework and GCP doesn't seem to have such test and Alibaba Cloud imports it as we do: https://github.com/kubernetes/cloud-provider-alibaba-cloud/blob/master/go.mod#L32

I see AWS provider works around this by having a separate go.mod for tests: https://github.com/kubernetes/cloud-provider-aws/blob/master/tests/e2e/go.mod

@ProbstDJakob: Would you want to try implementing AWS approach?

UPD: as for the regular code, we initialize k8s feature gates in the OCCM cmd:

_ "k8s.io/kubernetes/pkg/features" // add the kubernetes feature gates

https://github.com/kubernetes/kubernetes/blob/55f2bc10435160619d1ece8de49a1c0f8fcdf276/pkg/features/kube_features.go#L980-L982

Why do we even do that? I don't see that pattern in other cloud providers. Maybe this one can be removed.

@ProbstDJakob
Copy link
Contributor Author

I will look into it next week and open a PR, but what about the line in the occm/main.go? Is it safe to remove it or how should I handle that?

kayrus added a commit to kayrus/cloud-provider-openstack that referenced this issue Dec 11, 2023
@kayrus
Copy link
Contributor

kayrus commented Dec 11, 2023

The #2486 should fix this issue

@kayrus
Copy link
Contributor

kayrus commented Dec 11, 2023

Why do we even do that? I don't see that pattern in other cloud providers. Maybe this one can be removed.

Is it safe to remove it or how should I handle that?

I don't know what does it do. It was added in 0c8a774#diff-c19a66ed1fb964264d7bd09434b6bdbb184644ff0e64154c88d69e10acc26f97R35
If someone has time to investigate this code line, please go ahead.

@dulek
Copy link
Contributor

dulek commented Dec 14, 2023

Why do we even do that? I don't see that pattern in other cloud providers. Maybe this one can be removed.

Is it safe to remove it or how should I handle that?

I don't know what does it do. It was added in 0c8a774#diff-c19a66ed1fb964264d7bd09434b6bdbb184644ff0e64154c88d69e10acc26f97R35 If someone has time to investigate this code line, please go ahead.

@dims, maybe you have a clue why it was done?

@dulek
Copy link
Contributor

dulek commented Feb 28, 2024

@kayrus: Is this fixed…?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants