-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Build protos via docker #6548
Build protos via docker #6548
Conversation
With this change, you can build build protos from the root of a vitess checkout, without needing to have it checked out to "vitess.io/vitess" somewhere on your filesystem and being two directories up. Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
82d1324
to
d57b93c
Compare
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Makefile
Outdated
@@ -149,20 +149,14 @@ PROTO_SRC_NAMES = $(basename $(notdir $(PROTO_SRCS))) | |||
PROTO_GO_OUTS = $(foreach name, $(PROTO_SRC_NAMES), go/vt/proto/$(name)/$(name).pb.go) | |||
|
|||
# This rule rebuilds all the go files from the proto definitions for gRPC. | |||
proto: $(PROTO_GO_OUTS) | |||
|
|||
proto: $(PROTO_SRCS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should take over the proto target. At a minimum we should keep the old target to build the proto's on the local system if the developer would like to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you able to build those protos? The main reason I started making this change is because I could never get make proto
to work for me.
I'm happy to leave the original make target alone, I'm just curious.
Makefile
Outdated
goimports -w $(VTROOT)/go/vt/proto/$${name}/$${name}.pb.go; \ | ||
done | ||
docker build -t proto-builder -f docker/proto/Dockerfile . | ||
docker run --rm --mount type=bind,src=$(shell pwd)/go/vt/proto/,dst=/go/vt/proto/ proto-builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likey why you have to sudo below. Instead of bind mounting just use -v
to mount the directory and run the container as the current user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this mount
seems to have the unfortunate effect of making chmod-ing directories to 777
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm going to push up a commit switching to the -v
style
RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \ | ||
unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /protoc && \ | ||
mv /protoc/bin/protoc /usr/local/bin/ && \ | ||
rm -rf protoc-${PROTOC_VERSION}-linux-x86_64.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what the end use of this container would be, but I would support having it be built once and pushed to the vitess repo on docker hub. That would prevent the fetching of these dependencies every time we rebuild proto's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushing this up somewhere sounds like a great idea! Is that something that I can do, or does that require a vitess maintainer (I see references to pushing in the Release Instructions, so I don't want to push carelessly).
Definitely works for me, and more reliable and consistent than my |
Can you check if #6580 solves the problem? |
on my machine, #6580 does not work as expected: shlomi@sn-carbon:~/dev/github/vitessio/vitess$ make proto
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
...
(infinite) |
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
I believe I've fixed all the permissions issues with the resulting. generated protos, and also moved the docker-based proto generation to a separate make target, which I believe were the two biggest comments on this change. The main thing I think is outstanding is this comment about pushing the builder image up to a registry. |
@ajm188 for some reason GH won't let me re-run the failed tests. can you try? |
Hmmm, it looks like I'm missing the "Re-run all jobs" button, too. Did something change with permissions? |
Nope. I can do that on other PRs just not on this one. I'm going to try close followed by re-open. If that doesn't work maybe you could close this PR and open another one from the same branch. |
I see the button again after you did that. |
a few things still to be clarified/resolved:
|
Right now, anyone that has a local environment setup that can build the protos should be unaffected. For people that are having issues building protos (@shlomi-noach's issue, for example, is fixed by downgrading his install of protoc-gen-go to v1.23.0) can, assuming they have docker working locally, just switch to (I think eventually we should build everything in docker because it feels simpler to me for newcomers with nothing set up, but that doesn't have to be the case with this change).
On my branch, I did the following:
That extra diff seems to be added manually in 250caba, so the non-docker version seems to be working fine.
|
I'm still unable to |
I've cleared @dkhenry 's request for change since that change was applied. |
Actually, I'm having trouble with the docker build, too. I've just opened #7041 which seems to work well (for me). |
What issue did you run into? |
Sorry, I should have been more detailed. And... now that I came back to this, I can't reproduce and everything seems fine. What I got yesterday are successful builds but strange outputs; that is |
All, |
@shlomi-noach how is |
Now resolved... thanks to @deepthi. I had this going on:
and it seems I need to manually run |
This PR creates a dockerfile and build script for generating the go code from the .proto files.
I was playing around with the protos locally when I discovered that
make proto
did not work with the way I had cloned vitess (I think) (errors like/bin/bash: line 0: cd: /../../../src: No such file or directory
).After poking at it for a bit, I ended up deciding (but let me know if you think differently!) that going with a dockerized solution would probably be simpler to maintain. The main benefits I see are that we pin the version of
protoc
(we could also pinprotoc-gen-go
andgoimports
if we wanted) and that it doesn't rely on VTTOP or VTROOT in any way; you just need a vitess checkout and docker installed.Testing:
I'm not sure what version of protoc was used to generate these last time, because I definitely see changes, vtgate.pb.go, for example. I would guess pinning the protoc version lower could let us merge this change without impacting the protos (and then later we can bump the version and update the protos :D)I pinned proto-gen-go to 1.3.2 (found here), and now the only diff is the following in go/vt/proto/binlogdata/binlogdata.pb.go: