Makefile: replace protoc with buf#66913
Conversation
|
I haven't done the Bazel side of this yet, but wanted to see how the CIs feel about it for now. |
|
Looks fine so far. I'm concerned about the Bazel side of this -- |
|
The CLI is almost the same, though as seen here, From the docs it sounds like it is intended to otherwise be drop-in with just a couple exceptions that don't really affect us:
|
b9047b2 to
0226f49
Compare
|
@rickystewart It looks like bazel is actually already using its own protoc, not the one in c-deps/protobuf, so it doesn't seem to care except what we do to c-deps/protoc. The only bazel change I needed to make was configuring rewrite of the prometheus proto import, to match the changes I made to the include path on the Makefile side. So while we probably do want to fork and update The I also didn't remove the protoc submodule in this PR yet -- I have the commit that does so, but I was kinda thinking to wait until this lands, see if there's any fallout first? |
We actually need this one. So step 1 would be going over to the
It is using "its own
AFAIC this is a regression in the status of the Bazel migration -- I don't want the Bazel build and the |
rickystewart
left a comment
There was a problem hiding this comment.
(requesting changes for the above reasons to get this out of my queue)
|
@rickystewart |
|
This would apparently require some dev-inf investment. We have a team meeting tomorrow, I'll bring it up there and we'll settle on some next steps. |
|
Yeah, it looks like bazel does pass input descriptor sets for proto->proto dependencies. In the error, As long as they're producing the same output, I'm a little sad that we'll say |
|
Thanks for bringing this to our attention! A few things from the comments:
This is actually a bug on our part - this should not be true with Corollary: see #56863 (comment) for a discussion of how I tried to get
Let us test this out locally, we were not aware this was an option for
We want to have better support for bazel as a first-class citizen, we're happy to find 30 minutes to talk on video if your team is interested, would be a good use case. |
|
Also note we got |
|
See bufbuild/buf#350 and bufbuild/buf#351 for the first two issues. |
|
A couple updates on the Bazel side.
@bufdev What's the status of Context on the above: code generation for protobufs in Bazel is split into a two-step process, which you can see e.g. in this BUILD file. The first step ( |
We could also theoretically create a
I started investigating this today, and in short, it is possible and we should do it, but I would expect this to not be ready until as late as end of next week. There's a possibility I can completely hack it in tomorrow, but there's a lot of moving pieces. If you can give us that time though, we can do it. We actually like that you're hitting all of this for us, as we want to provide better support for Bazel, and you're finding the holes (not that we like that you're struggling though!).
Yep, we'll get it done. |
|
Also see bufbuild/buf#353, bufbuild/buf#357 |
Nah, it's not necessary.
No reason to go that hard I think, there's no real urgency to this AFAIK. Feel free to take your time and do it right :) When you have a release/SHA/whatever that supports |
|
OK we'll let you know - we'll get it done, there's some weeds to whack to get there though! |
|
@rickystewart given that a) it looks like we could add buf support to rules_go, even without any upstream changes and b) upstream is working on changes that'll make it an even simpler swap as a drop-in soon (thanks so much!), how do we feel about proceeding here, with the Makefile-side of things? I think my initial inclination would be towards merging this as is and then swapping bazel's |
rickystewart
left a comment
There was a problem hiding this comment.
@rickystewart given that a) it looks like we could add buf support to rules_go, even without any upstream changes and b) upstream is working on changes that'll make it an even simpler swap as a drop-in soon (thanks so much!), how do we feel about proceeding here, with the Makefile-side of things?
Sure. Go ahead and adjust that prometheus thing @bufdev mentioned.
Up to you whether you want to rm -rf c-deps/protobuf, but TBH I would rather see it done in this commit. We can just revert that change if we have to, and c-deps/protobuf isn't used for anything at this point, so it seems more confusing to just let it sit here.
|
#67091 for the follow-up work on the Bazel side. |
| github.com/axiomhq/hyperloglog v0.0.0-20181223111420-4b99d0c2c99e | ||
| github.com/bazelbuild/rules_go v0.26.0 | ||
| github.com/biogo/store v0.0.0-20160505134755-913427a1d5e8 | ||
| github.com/bufbuild/buf v0.42.1 |
There was a problem hiding this comment.
Also of note that we're on v0.43.2 now, but not a big deal
a366b7f to
2d391ce
Compare
There was a problem hiding this comment.
You can quash the client_model thing by deleting the build_directives from that repo declaration, so:
diff --git a/BUILD.bazel b/BUILD.bazel
index 116ce7b008..e91e319983 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -33,8 +33,8 @@ load("@bazel_gazelle//:def.bzl", "gazelle")
# gazelle:resolve proto proto gogoproto/gogo.proto @com_github_gogo_protobuf//gogoproto:gogo_proto
# gazelle:resolve proto go gogoproto/gogo.proto @com_github_gogo_protobuf//gogoproto
# gazelle:resolve proto go google/api/annotations.proto @org_golang_google_genproto//googleapis/api/annotations:go_default_library
-# gazelle:resolve proto client_model/io/prometheus/client/metrics.proto @com_github_prometheus_client_model//io/prometheus/client:client_proto
-# gazelle:resolve proto go client_model/io/prometheus/client/metrics.proto @com_github_prometheus_client_model//go
+# gazelle:resolve proto io/prometheus/client/metrics.proto @com_github_prometheus_client_model//io/prometheus/client:client_proto
+# gazelle:resolve proto go io/prometheus/client/metrics.proto @com_github_prometheus_client_model//go
# gazelle:resolve go github.com/prometheus/client_model/go @com_github_prometheus_client_model//go
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/cli_test @cockroach//pkg/cli:cli_test
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/sql/colflow_test @cockroach//pkg/sql/colflow:colflow_test
diff --git a/DEPS.bzl b/DEPS.bzl
index f227172116..f5a3770311 100644
--- a/DEPS.bzl
+++ b/DEPS.bzl
@@ -3403,9 +3403,6 @@ def go_deps():
)
go_repository(
name = "com_github_prometheus_client_model",
- build_directives = [
- "gazelle:proto_import_prefix client_model/",
- ],
build_file_proto_mode = "package",
importpath = "github.com/prometheus/client_model",
patch_args = ["-p1"],
diff --git a/pkg/ts/catalog/chart_catalog.proto b/pkg/ts/catalog/chart_catalog.proto
index deafc0bcc5..ac94793344 100644
--- a/pkg/ts/catalog/chart_catalog.proto
+++ b/pkg/ts/catalog/chart_catalog.proto
@@ -15,7 +15,7 @@ option go_package = "catalog";
import "ts/tspb/timeseries.proto";
import "gogoproto/gogo.proto";
-import "client_model/io/prometheus/client/metrics.proto";
+import "io/prometheus/client/metrics.proto";
// AxisUnits describes the Unit options available in the Admin UI. It is defined here
// as opposed to importing the value from the Admin UI because the existing pb doesn't
diff --git a/pkg/util/metric/metric.proto b/pkg/util/metric/metric.proto
index 5d9aca0c85..85027e7bd2 100644
--- a/pkg/util/metric/metric.proto
+++ b/pkg/util/metric/metric.proto
@@ -14,7 +14,7 @@ package cockroach.util.metric;
option go_package = "metric";
import "gogoproto/gogo.proto";
-import "client_model/io/prometheus/client/metrics.proto";
+import "io/prometheus/client/metrics.proto";
// metric.LabelPair is a proxy for io.prometheus.client.LabelPair.
// io.prometheus.client.LabelPair doesn't support gogoproto.marshaler
(... Plus whatever changes are needed in the Makefile to include the right path.)
|
aha, that was the magic line I needed to remove! Done. |
rickystewart
left a comment
There was a problem hiding this comment.
Thanks for your work on this @dt!
LGTM assuming CI doesn't complain.
|
ah, looks like you have a |
Release note: none.
This switches to use 'buf protoc' instead of protobuf/protoc to generate code from .proto files. This eliminates a large c-dep in favor of a pure go replacement, and has potential for further improvements as the buf protoc replacement includes options that could be explored to further improve performance, add more linting, etc. buf is slightly stricter than protoc about its include path, specifically it does not allow an entry in the include path that has a prefix another entry already on the include path. Previously we were passing such paths, e.g. vendor/github.com and vendor/github.com/cockroachdb/errors. This patch removes the broader parent, and adds a more spcecific include path for the only file that was using it (prometheus). However a future change that might be clearer would be to instead only add the broad base path and have the individual imports include their more specific paths within it directly. Release note: none.
Release note: none
|
TFTRs! bors r+ |
|
Build succeeded: |
|
Wow, David! Nice work. |
This switches to use 'buf protoc' instead of protobuf/protoc to generate
code from .proto files. This eliminates a large c-dep in favor of a pure
go replacement, and has potential for further improvements as the buf
protoc replacement includes options that could be explored to further
improve performance, add more linting, etc.
buf is slightly stricter than protoc about its include path, specifically
it does not allow an entry in the include path that has a prefix another
entry already on the include path. Previously we were passing such paths,
e.g. vendor/github.com and vendor/github.com/cockroachdb/errors. This
patch removes the broader parent, and adds a more spcecific include path
for the only file that was using it (prometheus). However a future change
that might be clearer would be to instead only add the broad base path
and have the individual imports include their more specific paths within it
directly.
Release note: none.