PaddlePaddle / PaddleCloud

PaddlePaddle Docker images and K8s operators for PaddleOCR/Detection developers to use on public/private cloud.
Apache License 2.0
283 stars 76 forks source link

Document how to reliably generate CRD code #582

Open helinwang opened 6 years ago

helinwang commented 6 years ago

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!

m3ngyang commented 6 years ago

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 commented 6 years ago

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

helinwang commented 6 years ago

@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.

m3ngyang commented 6 years ago

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