kubernetes: 'unknown revision v0.0.0' errors, seemingly due to 'require k8s.io/foo v0.0.0'
Summary: invalid version: unknown revision v0.0.0 or v0.0.0.zip: 404 Not Found errors can occur when a Go module or one of its dependencies is attempting to use at least one package within the k8s.io/kubernetes module as a library/dependency, which is unsupported and not recommended by the Kubernetes project.
Please see the 2023-01-10 update below.
What happened:
Observed unknown revision v0.0.0 errors when getting kubernetes modules from a module-based consumer.
In particular, getting the master versions of k8s.io/kubernetes and k8s.io/api fails with the tip version of Go.
This is a follow-up to https://github.com/golang/go/issues/27173#issuecomment-504807285, https://github.com/golang/go/issues/27173#issuecomment-505089424, and https://github.com/golang/go/issues/32776
How to reproduce it (as minimally and precisely as possible):
go get golang.org/dl/gotip && gotip download
export GOPROXY=direct
export GOSUMDB=off
export GOPATH=$(mktemp -d)
cd $(mktemp -d)
gotip mod init m
gotip get -v -d k8s.io/kubernetes@master # current master: 8c3b7d7679cc
gotip get -v -d k8s.io/api@master # current master: dcce3486da33
which fails with:
go: extracting k8s.io/api v0.0.0-20190620073856-dcce3486da33
go: downloading k8s.io/api v0.0.0
go get k8s.io/api@master: unknown revision v0.0.0
Anything else we need to know?:
According to https://github.com/golang/go/issues/32776, it is apparently also possible to hit the unknown revision v0.0.0 error for kubernetes using Go 1.12, though the steps are different.
The v0.0.0 might be set in update-vendor.sh, but not sure:
@bcmills wrote in https://github.com/golang/go/issues/27173#issuecomment-505089424:
I don’t know why go1.12.6 doesn’t detect the error in k8s.io/kubernetes, but gotip is correct to fail that sequence.
k8s.io/kubernetes requires k8s.io/api v0.0.0 here. There is no such version of k8s.io/api tagged, and because the repo doesn’t have any semver-style tags, v0.0.0- is the correct pseudo-version prefix for its commits.
As far as I can tell, because k8s.io/kubernetes relies so heavily on replace directives to pin its dependencies it can only be built in module mode if it is the main module, or if the main module replicates its replace directives more-or-less exactly.
Environment:
- Kubernetes version (use
kubectl version):
k8s.io/kubernetes@master is 8c3b7d7679cc k8s.io/api@master is dcce3486da33
CC @liggitt, @sttts, @nikhita, @joshmsamuels
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 51 (28 by maintainers)
Commits related to this issue
- Update Kubernetes dependencies to 1.15 Updating required a different approach this time around: upstream switched to Go modules consistently but does not support consuming k8s.io/kubernetes directly.... — committed to timoreimann/digitalocean-cloud-controller-manager by timoreimann 5 years ago
- Added go.mod Cannot use go module converted from glide due to error: https://github.com/kubernetes/kubernetes/issues/79384 — committed to werf/3p-helm by distorhead 5 years ago
- Added go.mod Cannot use go module converted from glide due to error: https://github.com/kubernetes/kubernetes/issues/79384 — committed to werf/3p-helm by distorhead 5 years ago
- Added go.mod Cannot use go module converted from glide due to error: https://github.com/kubernetes/kubernetes/issues/79384 — committed to werf/3p-helm by distorhead 5 years ago
- Added go.mod Cannot use go module converted from glide due to error: https://github.com/kubernetes/kubernetes/issues/79384 — committed to werf/3p-helm by distorhead 5 years ago
- Added go.mod Cannot use go module converted from glide due to error: https://github.com/kubernetes/kubernetes/issues/79384 — committed to werf/3p-helm by distorhead 5 years ago
- Added go.mod Cannot use go module converted from glide due to error: https://github.com/kubernetes/kubernetes/issues/79384 — committed to werf/3p-helm by distorhead 5 years ago
- go.mod: back out of relying on k8s.io/kubernetes, which should not be pulled in See-Also: https://github.com/kubernetes/kubernetes/issues/79384 — committed to ripta/spectacles by ripta 5 years ago
- Add the k8s version switch script from: https://github.com/kubernetes/kubernetes/issues/79384#issuecomment-521493597 Signed-off-by: Nikolay Nikolaev <nnikolay@vmware.com> — committed to nickolaev/networkservicemesh by deleted user 5 years ago
- Add the k8s version switch script from: https://github.com/kubernetes/kubernetes/issues/79384#issuecomment-521493597 Signed-off-by: Nikolay Nikolaev <nnikolay@vmware.com> — committed to nickolaev/networkservicemesh by deleted user 5 years ago
- Update for k8s 1.15.3 (#1519) * Update client-go and bump to 1.14.5 Signed-off-by: Nikolay Nikolaev <nnikolay@vmware.com> * k8s 1.14.6 Signed-off-by: Nikolay Nikolaev <nnikolay@vmware.com> ... — committed to networkservicemesh/networkservicemesh by deleted user 5 years ago
- Add go mod files See https://github.com/kubernetes/kubernetes/issues/79384 for details on how to update K8s dependencies. — committed to rojkov/intel-device-plugins-for-kubernetes by deleted user 5 years ago
- Add support for go mod See https://github.com/kubernetes/kubernetes/issues/79384 for details on how to update K8s dependencies. — committed to rojkov/intel-device-plugins-for-kubernetes by deleted user 5 years ago
- Add support for go mod See https://github.com/kubernetes/kubernetes/issues/79384 for details on how to update K8s dependencies. — committed to rojkov/intel-device-plugins-for-kubernetes by deleted user 5 years ago
- Add support for go mod See https://github.com/kubernetes/kubernetes/issues/79384 for details on how to update K8s dependencies. — committed to rojkov/intel-device-plugins-for-kubernetes by deleted user 5 years ago
- Add support for go mod See https://github.com/kubernetes/kubernetes/issues/79384 for details on how to update K8s dependencies. — committed to rojkov/intel-device-plugins-for-kubernetes by deleted user 5 years ago
- Resolve dependency issues Includes a script from https://github.com/kubernetes/kubernetes/issues/79384#issuecomment-521493597 to update K8S dependencies in a sane way. — committed to fluxcd/helm-operator by hiddeco 5 years ago
- Resolve dependency issues Includes a script from https://github.com/kubernetes/kubernetes/issues/79384#issuecomment-521493597 to update K8S dependencies in a sane way. — committed to fluxcd/helm-operator by hiddeco 5 years ago
- Added go.mod Cannot use go module converted from glide due to error: https://github.com/kubernetes/kubernetes/issues/79384. Update k8s.io go deps to 1.16.0. — committed to werf/3p-helm by distorhead 5 years ago
- remove dependency on k8s.io/kubernetes ref kubernetes/kubernetes#79384 — committed to mackerelio/mackerel-container-agent by lufia 5 years ago
For anyone else who hits this issue, after much weeping and gnashing of teeth, this is the little script I wrote to switch kubernetes versions:
Update on 2023-01-10:
As noted later in this issue, use of packages within the
k8s.io/kubernetesmodule as a library/dependency is unsupported and not recommended. The modules intended to be consumed as libraries are published with go.mod files that do not require any replace directives.That is noted in the k8s.io/kubernetes repo README as well:
If in spite of that, other projects want to use k8s.io/kubernetes as a library, replicating the replace directives from the k8s.io/kubernetes go.mod file to point to appropriate tags of the other k8s.io modules is required.
Original comment follows:
pin all the dependencies to a matching level of k8s.io/kubernetes (these all correspond to the
kubernetes-1.15.0tag):Copied from the referenced golang issue thread:
k8s.io/kubernetes is not primarily intended to be consumed as a module. Only the published subcomponents are (and go get works properly with those).
If you want to consume k8s.io/kubernetes as a module, you’d probably need to add require directives for matching versions of all of the subcomponents, rather than using go get
/close
This might be a Bad Idea™, but appending this to the consumer
go.modfile at least compiled the failing example in https://github.com/golang/go/issues/32776#issuecomment-505614864:8c3b7d7679ccf368was master on k8s.io/kubernetes as of a couple days ago.That was generated by taking the
replacedirectives that point to the relative filesystem path./staging/...ink8s.io/kubernetes/go.mod, and using those to make newreplacedirectives that instead point tok8s.io/kubernetes/staging/...at revision8c3b7d7679ccf368:The results of that can then be added to a consumer’s
go.modfile.@bcmills I completely get that. But people who are “doing it wrong” by depending on
k8s.io/kubernetesare not the only ones that are broken. Anyone that even has it as a transitive dependency is broken. I don’t want to depend onk8s.io/kubernetes… but I have to depend on helm which does depend onk8s.io/kubernetesso I have no choice@abuisine nice script
As of Kubernetes v1.17.0+, it is even easier to find the corresponding tags for these repositories. Simply use v0.x.y to correspond to any v1.x.y Kubernetes release over v1.17.0 (note the v0 instead of v1…).
For example, for Kubernetes v1.17.0, the published staging repositories are all tagged with v0.17.0.
See https://github.com/kubernetes/client-go/blob/master/INSTALL.md#add-client-go-as-a-dependency for details
Just a heads up, if you run goimports on something that used to have k8s.io/api e.g.
core "k8s.io/api/core/v1", you might find it addscore "k8s.io/kubernetes/pkg/apis/core"instead. The former is used by kubebuilder and others.Make sure to run it on the latest version otherwise it might not work for me it was v1.18.2
yes
This doesn’t just break the people trying to depend on kubernetes, but also people depending on others depending on kubernetes. I cannot do
go get foobecausefoodepends on KubernetesFwiw if
go getis being used to download all dependencies,go mod downloadworks and does the same thing…we’ve hoisted this info into the main repo readme at https://github.com/kubernetes/kubernetes/#to-start-using-k8s
I’ll update my first comment on this issue to include this info
Why is this still unfixed? Why is it acceptable for people to be required to add a bunch of random
replacedirectives using a third-party script from a random issue that’s closed?I’m still getting the very same issue today after clearing most of my
go.modto get the very latest versions of everything:just share one case from Volcano: we’re going to use algorithms of scheduler from upstream to make keep backward compatibility 😃
You can now use v0.x.y for the published components that correspond to Kubernetes v1.x.y without needing to figure out the timestamps/hashes. This is available in 1.15.10+, 1.16.4+, and 1.17.0+