Don't check in generated code, part 1#25978
Don't check in generated code, part 1#25978k8s-github-robot merged 18 commits intokubernetes:masterfrom
Conversation
cmd/libs/go2idl/args/args.go
Outdated
There was a problem hiding this comment.
Unfortunately no - we need to identify which other packages will be generated for protobuf so we know whether to embed the message definition into the particular package, or to reuse an existing definition.
There was a problem hiding this comment.
Is this a case of we could start with a single file and process all deps of that file, and eventually emit a single file? Can you describe the algorithm for protobuf a bit more?
There was a problem hiding this comment.
I realized even deep_copy doesn't start with a root file and only process symbols linked transitively from there. I have re-pushed this so that it uses all files in the same dir as deps for a rebuild, except generated files.
736bd6c to
6e3523b
Compare
Makefile
Outdated
There was a problem hiding this comment.
@wojtek-t @lavalamp the args part of go2idl says that output pkg is supported, but it looks like nothing but set-gen supports it. Trivial attempts at changing the output path for deepcopy did not work. Clue me in? Or shoot this idea down. It would be nice to have the generated files in a wholly separate pkg I think.
6e3523b to
97e1607
Compare
|
@thockin - do you want to have this in 1.3? If not, let sit on that for some time. |
|
Of course. I feel like it's a few hours from working, but it's mostly in
|
97e1607 to
da69838
Compare
|
A new push of this is up. The new push incorporates Daniel's registration Alas: The new generator is not recognizing On Sat, May 21, 2016 at 8:28 AM, Tim Hockin notifications@github.com
|
da69838 to
7856752
Compare
7856752 to
f93f492
Compare
|
This PR is a totally half-baked mess, but I think I have actually achieved deep-copy and conversion to be autogenerated. To do it, I had to bend As of right now, it actually compiles. Not sure if any symbols are missing or whatnot. |
c888da0 to
9e7ea33
Compare
9e7ea33 to
75a8d5a
Compare
|
For third party clients I would highly recommend vendoring. Kube
workflow is not designed to guarantee that the code in our packages
are safe to imported externally. It's certainly possible, but it is
not a good idea.
And again, this is the work being done by Chao to ensure there is a
safe library to import from.
|
I think it's the right thing to do, but the harm is that it's a huge PR and it needs constant rebases. |
|
Throwing out a proposal, though I doubt it will stick. What if we built with a build-tag which out-of-tree users would not use. If the tag was specified, we would link the code that triggers the need for autogenerated code to be present. For normal users (go get) you would not get that code. @lavalamp @caesarxuchao this could provide temporary respite for people linking the client and getting crap we don't want....? Sadly Go has no notion of "weak symbols" like good old C and C++. The longer this sits the harder it will be to roll back. What irks me most is not rebasing it and trying again, it's that I don't actually know how to fix this once and for all. Which means it may be a long time before I get back to it, which means it will probably rot. If we don't have clarity by tomorrow AM, I will deliver or approve delivery of the coup-de-grace. Does anyone have time to work up a rollback PR tonight? I can't do it until tomorrow. |
|
I am opposed to rolling this back. We can't check in generated code into the main repo. It's hostile to source control. We likely will eventually generate proto files asynchronously into another repo that is dedicated to that purpose. The "standard Go tools" are inadequate for our use case. The code in pkg/api and pkg/apis is not intended for use by others. Do we need supported client libraries? Yes. Do we have any? No. If you'd like to help develop client libraries, please participate in the API machinery SIG. We need help implementing support for Swagger 2.0, which could then be used to generate clients. Is anything broken that wasn't already not supposed to work? @thockin |
|
Another alternative is to go get from the release-1.3 branch. |
|
See also #11606 |
|
I don't want to roll back, but I have ideas on how we can maybe Tomorrow is busy but I will try to get some time with @lavalamp et al to On Jul 13, 2016 10:44 PM, "Brian Grant" notifications@github.com wrote:
|
|
I wasn't aware that That said, there's not really a good solution that doesn't involve completely restructuring the code, so maybe it's just a trade-off we need to take for now. |
|
ref #8830 |
|
@spxtr AFAIK, we do not yet have a client that is supported for use outside our own repos, especially for anyone who extracts a subset of the kubernetes repo. pkg/api is part of the apiserver implementation. Even the versioned types aren't guaranteed to be stable so long as the json doesn't change in a non-backward-compatible way. IMO, we won't have a supported client until it's in another repo. |
|
Swagger is our recommended means of getting the API schema, not importing our implementation. |
|
@bgrant0607 it appears as though neither of those alternatives support the v1beta1 resources, understandably, but their utility is limited. I'm trying to avoid having custom builds for CI, but it can be done if currently cleaning up kubernetes development flow is more important than maintaining compatibility with the standard Go toolchain. @smarterclayton versioning is a good option for those building executables, but it is my understanding that when writing libraries, it should be avoided if possible. But perhaps my understanding is out of date or this falls into the "not possible" category. Thanks for all the work, explanations, and suggestions, especially @thockin . |
|
@ddgenome Could you use the release-1.3 branch for now? |
|
My local build is working because I have not updated the version of kubernetes under GO = go
GO_FLAGS = -v
GO_ARGS = ./...
all: clean vet
get: k8
$(GO) get $(GO_FLAGS) $(GO_ARGS)
generate: get
$(GO) generate $(GO_FLAGS) $(GO_ARGS)
build: generate
$(GO) build $(GO_FLAGS) $(GO_ARGS)
test: build
$(GO) test $(GO_FLAGS) $(GO_ARGS)
vet: test
$(GO) vet $(GO_FLAGS) $(GO_ARGS)
clean:
$(GO) clean $(GO_FLAGS) $(GO_ARGS)
.PHONY: all clean get build test vet
GO_SRC = $(GOPATH)/src
K8SIO_PATH = $(GO_SRC)/k8s.io
K8_GO_PATH = $(K8SIO_PATH)/kubernetes
K8_REPO = https://github.com/kubernetes/kubernetes
K8_BRANCH = release-1.3
k8:
mkdir -p $(K8SIO_PATH)
git clone --branch $(K8_BRANCH) $(K8_REPO) $(K8_GO_PATH)
.PHONY: k8 |
|
Is the plan to include the auto-generated code in the release branches? |
|
The plan is roughly to have a whole distinct repo that holds the Getting there is a little tricker. On Thu, Jul 14, 2016 at 8:43 AM, David Dooling notifications@github.com
|
|
I sort of mean "in the mean time". That is, is the plan that release branches have the full client code until a separate repo with the fully-formed and minimal-dependency-tree-ized client libs exists? |
|
@thockin "... changes to the API will not be e2e tested until the re-vendoring..." "The plan is roughly to have a whole distinct repo that holds the fully-formed and minimal-dependency-tree-ized client libs." The same argument applies to the client lib. However, the API has fewer dependencies than the client, so re-vendoring it is much simpler. @bgrant0607 "We can't check in generated code into the main repo. It's hostile to source control." So are Godeps and vendoring. I agree that the Go tool kit has woefully inadequate support for meta-programming, which is why we check in auto-generated code. That's why I think we should just put the existing code into 2 repos: one to generate the code, and one that is generated. This eliminates management problems, and still plays nicely with Go. |
|
A few of us put heads together today and came up with what we think is a On Thu, Jul 14, 2016 at 2:04 PM, Q-Lee notifications@github.com wrote:
|
|
/cc @thockin @lixiaobing10051267 reports an error when I meet the similar error too. Do we need to config something after calling |
Kubernetes 1.3 advertises an official Go client library on this page. That client library, |
|
@peterbourgon Thanks for pointing that out. Unfortunately, that document is not correct. However, if you import from the release branch, and it works now, it should continue to work, since that branch will be fairly static. |
|
I am offering #29017 to re-add generated files, but leave them being generated on the fly. Once we have a real go-get compatible client we can re-remove them. Please put thoughts on that PR. |
|
heads up-- As @foxish just noticed, if you build at head right now, you On Fri, Jul 15, 2016 at 10:35 AM, Tim Hockin notifications@github.com
|
This PR is a first step towards not commiting generated files, which make up a huge portion of "needs rebase" errors. It only handles deep-copy generation and conversion generation. More will come later, if the model passes muster.
This is a mega-PR. Sorry. It was necessary to do 2 generators to convince myself it worked, and the evolution of the techniques warranted multiple commits. I have tried to keep the commits self-contained and reviewable.
A quick summary of the major points in the series:
makerather than the various hack/* scripts. The hack scripts still exist, but give a warning to use make instead, and then they do what they did before, so it should be compatible.Net result: if you run "make", it will rebuild any deepcopy or conversion files it needs. It takes a few seconds to figure out there's nothing to do, but it should be a net savings. There is more to do, and we can follow this up with other generators being converted, some of which are MUCH slower than these 2.
@wojtek-t @lavalamp @smarterclayton @bgrant0607 @mikedanese @madhusudancs