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

error when fetching volcano with go mod vendor #810

Closed
nicklhy opened this issue May 16, 2020 · 9 comments
Closed

error when fetching volcano with go mod vendor #810

nicklhy opened this issue May 16, 2020 · 9 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@nicklhy
Copy link

nicklhy commented May 16, 2020

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

I have a small go program that tries to create a volcano job. But when I execute go run main.go, an error like below showed up:

$ go run ./main.go 
go: finding module for package volcano.sh/volcano/pkg/apis/batch/v1alpha1
go: found volcano.sh/volcano/pkg/apis/batch/v1alpha1 in volcano.sh/volcano v0.4.0
go: volcano.sh/[email protected] requires
        k8s.io/[email protected]: reading https://goproxy.cn/k8s.io/api/@v/v0.0.0.mod: 404 Not Found
        server response: not found: k8s.io/[email protected]: invalid version: unknown revision v0.0.0

What you expected to happen:
The program should run with no problem.

How to reproduce it (as minimally and precisely as possible):
Save the below code to a file named main.go

package main

import (
        batchv1alpha1 "volcano.sh/volcano/pkg/apis/batch/v1alpha1"
)

func main() {
        _ = batchv1alpha1.Job{}
}

Then, execute go run main.go.

@volcano-sh-bot volcano-sh-bot added the kind/bug Categorizes issue or PR as related to a bug. label May 16, 2020
@k82cn
Copy link
Member

k82cn commented May 17, 2020

/cc @hzxuzhonghu

@hzxuzhonghu
Copy link
Collaborator

@nicklhy I would suggest you look at the pr I proposed in spark operator https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/pull/887/files#diff-37aff102a57d3d7b797f152915a6dc16R38

Also can you show me your go.mod?

@nicklhy
Copy link
Author

nicklhy commented May 18, 2020

@hzxuzhonghu As I mentioned, this problem showed up when I tried to run the simple main.go above. At that time, the go.mod was just being generated by go mod vendor and has no "require" section.
I noticed the pr you mentioned set the version of k8s client to "v0.16.6". Then, I tried to add the specific version of some packages in go.mod manually. The problem still exists

$ cat main.go 
package main

import (
        batchv1alpha1 "volcano.sh/volcano/pkg/apis/batch/v1alpha1"
)

func main() {
        _ = batchv1alpha1.Job{}
}
$ cat go.mod 
module test2

go 1.13

require (
        k8s.io/api v0.16.6
        k8s.io/client-go v0.16.9-beta.0
        k8s.io/kubernetes v1.16.2
        volcano.sh/volcano v0.4.0
)
$ go mod vendor
go: k8s.io/[email protected] requires
        k8s.io/[email protected]: reading https://goproxy.cn/k8s.io/api/@v/v0.0.0.mod: 404 Not Found

BTW, I set GO111MODULE=on and GOPROXY=https://goproxy.cn

@nicklhy
Copy link
Author

nicklhy commented May 18, 2020

Oh, just made it work by adding extra "replace" section in my go.mod.

replace (
	k8s.io/api => k8s.io/api v0.0.0-20200131112707-d64dbec685a4
	k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20200318010308-c96942bf1b43
	k8s.io/apimachinery => k8s.io/apimachinery v0.16.9-beta.0
	k8s.io/apiserver => k8s.io/apiserver v0.0.0-20200317213526-62c18ca8f66b
	k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20200228051546-a99b7f303206
	k8s.io/client-go => k8s.io/client-go v0.0.0-20191016111102-bec269661e48
	k8s.io/cloud-provider => k8s.io/cloud-provider v0.0.0-20200228053305-d368059ead1c
	k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.0.0-20200228053038-8bbe56c26119
	k8s.io/code-generator => k8s.io/code-generator v0.16.9-beta.0
	k8s.io/component-base => k8s.io/component-base v0.16.9-beta.0
	k8s.io/cri-api => k8s.io/cri-api v0.16.9-beta.0
	k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.0.0-20200228053533-d83d9540380e
	k8s.io/gengo => k8s.io/gengo v0.0.0-20190822140433-26a664648505
	k8s.io/heapster => k8s.io/heapster v1.2.0-beta.1
	k8s.io/klog => k8s.io/klog v0.4.0
	k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.0.0-20200228045702-699a8508e8d2
	k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.0.0-20200228052810-d1f697fa5379
	k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf
	k8s.io/kube-proxy => k8s.io/kube-proxy v0.0.0-20200228052049-a6119a74791a
	k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.0.0-20200228052541-0195892e09a0
	k8s.io/kubectl => k8s.io/kubectl v0.0.0-20200228054512-419760c9116d
	k8s.io/kubelet => k8s.io/kubelet v0.0.0-20200131120825-905bd8eea4c4
	k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20200317194326-32f35d4b17b4
	k8s.io/metrics => k8s.io/metrics v0.0.0-20200228051301-c298383a72cb
	k8s.io/node-api => k8s.io/node-api v0.0.0-20200228054017-076d0760c5f1
	k8s.io/repo-infra => k8s.io/repo-infra v0.0.0-20181204233714-00fe14e3d1a3
	k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.0.0-20200228050048-9291aec797aa
	k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.0.0-20200228051820-6fc9c909879b
	k8s.io/sample-controller => k8s.io/sample-controller v0.0.0-20200228050512-c37f031c4cf9
)

I am new to golang, but is it a normal step to add these version replacement lines in go.mod manually? I expect it should work by default before.

@vincent-pli
Copy link

I think the v0.0.0 is caused by direct import k8s.io/kubernetes rather than use its published staging repos, e.g. k8s.io/api, k8s.io/client-go

See the link:
google/go-containerregistry#496

@hzxuzhonghu
Copy link
Collaborator

Correct, for k8s dependencies, it requires to import the same version.

@SkinyMonkey
Copy link

SkinyMonkey commented Dec 11, 2020

Doing all those replaces seems a bit overkill and even dirty, is there another solution?

@k82cn
Copy link
Member

k82cn commented Dec 12, 2020

hm... it's better to separate volcano.sh/apis to a standalone repo, so you can generate client according to your environment.

@k82cn
Copy link
Member

k82cn commented Dec 12, 2020

xref #1155

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

6 participants