PaddleCloud icon indicating copy to clipboard operation
PaddleCloud copied to clipboard

Document how to reliably generate CRD code

Open helinwang opened this issue 7 years ago • 4 comments

Currently go test $(glide novendor) fails with the output:

ok  	github.com/PaddlePaddle/cloud/go/filemanager/pfsmodules	0.032s
ok  	github.com/PaddlePaddle/cloud/go/filemanager/pfsserver	0.006s
ok  	github.com/PaddlePaddle/cloud/go/utils/config	0.037s
# github.com/PaddlePaddle/cloud/go/pkg/apis/paddlepaddle/v1alpha1
pkg/apis/paddlepaddle/v1alpha1/register.go:25: cannot use TrainingJob literal (type *TrainingJob) as type runtime.Object in argument to scheme.AddKnownTypes:
	*TrainingJob does not implement runtime.Object (missing DeepCopyObject method)
pkg/apis/paddlepaddle/v1alpha1/register.go:26: cannot use TrainingJobList literal (type *TrainingJobList) as type runtime.Object in argument to scheme.AddKnownTypes:
	*TrainingJobList does not implement runtime.Object (missing DeepCopyObject method)
?   	github.com/PaddlePaddle/cloud/go/utils/kubeutil	[no test files]
?   	github.com/PaddlePaddle/cloud/go/utils/pathutil	[no test files]
ok  	github.com/PaddlePaddle/cloud/go/utils/restclient	0.061s
?   	github.com/PaddlePaddle/cloud/go/paddlecloud	[no test files]
?   	github.com/PaddlePaddle/cloud/go/cmd/edl	[no test files]
?   	github.com/PaddlePaddle/cloud/go/cmd/paddlecloud	[no test files]
?   	github.com/PaddlePaddle/cloud/go/cmd/paddlectl	[no test files]
?   	github.com/PaddlePaddle/cloud/go/cmd/pfsserver	[no test files]
?   	github.com/PaddlePaddle/cloud/go/paddlectl	[no test files]
?   	github.com/PaddlePaddle/cloud/go/pkg/apis/paddlepaddle	[no test files]

This is due to the Kubernets CRD need developer to run code generation commands before the code could compile.

I tried to follow the commands in https://github.com/PaddlePaddle/cloud/blob/develop/.travis.yml#L15-L18 but go test $(glide novendor) still failed with:

pkg/client/clientset/versioned/clientset.go:21:2: cannot find package "github.com/PaddlePaddle/cloud/go/pkg/client/clientset/versioned/typed/paddlepaddle/v1alpha1" in any of:
	/gopath/src/github.com/PaddlePaddle/cloud/go/vendor/github.com/PaddlePaddle/cloud/go/pkg/client/clientset/versioned/typed/paddlepaddle/v1alpha1 (vendor tree)
	/usr/local/go/src/github.com/PaddlePaddle/cloud/go/pkg/client/clientset/versioned/typed/paddlepaddle/v1alpha1 (from $GOROOT)
	/gopath/src/github.com/PaddlePaddle/cloud/go/pkg/client/clientset/versioned/typed/paddlepaddle/v1alpha1 (from $GOPATH)
pkg/client/clientset/versioned/fake/clientset_generated.go:22:2: cannot find package "github.com/PaddlePaddle/cloud/go/pkg/client/clientset/versioned/typed/paddlepaddle/v1alpha1/fake" in any of:
	/gopath/src/github.com/PaddlePaddle/cloud/go/vendor/github.com/PaddlePaddle/cloud/go/pkg/client/clientset/versioned/typed/paddlepaddle/v1alpha1/fake (vendor tree)
	/usr/local/go/src/github.com/PaddlePaddle/cloud/go/pkg/client/clientset/versioned/typed/paddlepaddle/v1alpha1/fake (from $GOROOT)
	/gopath/src/github.com/PaddlePaddle/cloud/go/pkg/client/clientset/versioned/typed/paddlepaddle/v1alpha1/fake (from $GOPATH)

I guess this is due to go get k8s.io/kubernetes used in the generation process is not tagged to a specific version.

Could we document how to reliably generate the required code, so that other developers could test all packages inside go folder without running into error? Thanks!

CC: @m3ngyang : could you take a look? Thanks for contributing!

helinwang avatar Feb 02 '18 19:02 helinwang

I update related codes in #565 , but maybe the pr is too large to review. And I'll submit several requests to solve the problem.

m3ngyang avatar Feb 03 '18 03:02 m3ngyang

An easy to avoid the problem is to skip pkg dir when running go test.

m3ngyang avatar Feb 03 '18 03:02 m3ngyang

@m3ngyang Thanks for your reply! The PR https://github.com/PaddlePaddle/cloud/pull/565 does not contain documentation for how to generate the CRD code. I think we need the documentation for that. It would be great if you can write a documentation for it since you are the one that most familiar with CRD. I will review for you.

In this case we should either have a document about how to generate the CRD code to make go test $(glide nv) pass, or have a document saying why go test $(glide nv) fails and please ignore the failure message for the CRD package. I think the former is the better solution.

helinwang avatar Feb 05 '18 18:02 helinwang

ok, I will submit a pr to describe how to generate codes for crd in this readme doc

m3ngyang avatar Feb 06 '18 02:02 m3ngyang