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

Generator only works if k8s.io/apimachinery is in the $GOPATH #21

Closed
markmandel opened this issue Nov 4, 2017 · 15 comments
Closed

Generator only works if k8s.io/apimachinery is in the $GOPATH #21

markmandel opened this issue Nov 4, 2017 · 15 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@markmandel
Copy link
Contributor

Whenever I attempt to run update-codegen.sh , but constantly get the below stacktrace.

Generating deepcopy funcs
F1104 02:57:44.419529      35 main.go:79] Error: Failed executing generator: some packages had errors:
type "k8s.io/apimachinery/pkg/runtime.Object" in k8s:deepcopy-gen:interfaces tag of type k8s.io/apimachinery/pkg/runtime.Object is not an interface, but: ""
goroutine 1 [running]:
k8s.io/code-generator/vendor/github.com/golang/glog.stacks(0xc420136b00, 0xc42012b080, 0x104, 0x15a)
        /go/src/k8s.io/code-generator/vendor/github.com/golang/glog/glog.go:766 +0xa7
k8s.io/code-generator/vendor/github.com/golang/glog.(*loggingT).output(0x83eb60, 0xc400000003, 0xc4200cf1e0, 0x81ea9f, 0x7, 0x4f, 0x0)
        /go/src/k8s.io/code-generator/vendor/github.com/golang/glog/glog.go:717 +0x348
k8s.io/code-generator/vendor/github.com/golang/glog.(*loggingT).printf(0x83eb60, 0x3, 0x6ebfc7, 0x9, 0xc4200e7f48, 0x1, 0x1)
        /go/src/k8s.io/code-generator/vendor/github.com/golang/glog/glog.go:655 +0x14f
k8s.io/code-generator/vendor/github.com/golang/glog.Fatalf(0x6ebfc7, 0x9, 0xc4200e7f48, 0x1, 0x1)
        /go/src/k8s.io/code-generator/vendor/github.com/golang/glog/glog.go:1145 +0x67
main.main()
        /go/src/k8s.io/code-generator/cmd/deepcopy-gen/main.go:79 +0x253

I created a simple test case using a Dockerfile below, using the sample-controller example, which replicates the problem.

FROM golang:1.9.2

ENV PATH=$PATH:/go/bin
RUN go get -u k8s.io/code-generator/...
RUN go get -d github.com/kubernetes/sample-controller
RUN mkdir -p /go/src/k8s.io/kubernetes/hack/boilerplate && touch /go/src/k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt
WORKDIR /
RUN CODEGEN_PKG=/go/src/k8s.io/code-generator /go/src/github.com/kubernetes/sample-controller/hack/update-codegen.sh

Help?

@markmandel
Copy link
Contributor Author

markmandel commented Nov 4, 2017

I worked out the issue - this doesn't work unless k8s.io/apimachinery is in the GOPATH, if it is just vendored, then deepcopy can't find it. At the very least, this needs to be documented somewhere, but it would be great if the vendored version worked as well.

Changed title to represent the actual issue.

@markmandel markmandel changed the title "k8s.io/apimachinery/pkg/runtime.Object" in k8s:deepcopy-gen:interfaces tag of type k8s.io/apimachinery/pkg/runtime.Object is not an interface. Generator only works if k8s.io/apimachinery is in the $GOPATH Nov 5, 2017
@jinghzhu
Copy link

+1 for fix or documentation.

I encounter the same issue and only find the solution mentioned before by Google.

@sttts
Copy link
Contributor

sttts commented Dec 12, 2017

@markmandel @jinghzhu do you have a small example repo where this can be seen?

@markmandel
Copy link
Contributor Author

@sttts you can copy the above section into a Dockerfile and do a docker build . and see the failure in action 😄

@sttts
Copy link
Contributor

sttts commented Dec 13, 2017

The cause for the issue described above is that the generators are not called from the sample-apiserver directory. Only then gengo (the Golang parsing library below) can pick up the vendor/ directory properly. The following Dockerfile passes the deepcopy-gen call, but fails at client-gen (compare kubernetes/kubernetes#57143 for a fix).

FROM golang:1.9.2

ENV PATH=$PATH:/go/bin
ENV GOPATH=/go
RUN go get -u k8s.io/code-generator/...
RUN go get -d k8s.io/sample-controller
RUN ls -l /go/src/k8s.io
RUN mkdir -p /go/src/k8s.io/kubernetes/hack/boilerplate && touch /go/src/k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt
WORKDIR /go/src/k8s.io/sample-controller
RUN CODEGEN_PKG=../../k8s.io/code-generator bash -xe hack/update-codegen.sh

@sttts
Copy link
Contributor

sttts commented Dec 13, 2017

PR welcome to improve our codegen shell scripts to cope with out-of-dir invocations.

@sttts
Copy link
Contributor

sttts commented Dec 13, 2017

Also note that the package is called k8s.io/sample-controller, not github.com/kubernetes/sample-controller.

@rahulkrishnanfs
Copy link

I am facing the same issue

@sttts
Copy link
Contributor

sttts commented Dec 29, 2017

@rahulkrishnanfs compare my comment #21 (comment). You have to call the generator script with a relative CODEGEN_PKG. Does it help?

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 29, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 28, 2018
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

nrb added a commit to nrb/velero that referenced this issue Jul 29, 2019
If running locally/on CircleCI, the code generators must be run from
within the Velero directory in order to properly find all the types.

See kubernetes/code-generator#21

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
nrb added a commit to nrb/velero that referenced this issue Aug 1, 2019
If running locally/on CircleCI, the code generators must be run from
within the Velero directory in order to properly find all the types.

See kubernetes/code-generator#21

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
@mattysweeps
Copy link

/reopen

See kubernetes/kubernetes#79149 (comment)
Code generator users are still running into this issue.

Either the documentation should inform users to prepare their GOPATHS with the necessary dependencies or the code-generator be improved so it no longer has this requirement.

@k8s-ci-robot
Copy link

@mattysweeps: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

See kubernetes/kubernetes#79149 (comment)
Code generator users are still running into this issue.

Either the documentation should inform users to prepare their GOPATHS with the necessary dependencies or the code-generator be improved so it no longer has this requirement.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@mattysweeps
Copy link

@markmandel please consider reopening this issue. I see no evidence that it has been solved, and users are still running into issues. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

7 participants