Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

go.mod: upgrade grpc-gateway to v2 #134964

Closed
wants to merge 17 commits into from
Closed

go.mod: upgrade grpc-gateway to v2 #134964

wants to merge 17 commits into from

Conversation

tbg
Copy link
Member

@tbg tbg commented Nov 12, 2024

This PR is an offshoot from attempting to upgrade gRPC.
It turned out in the end that we can upgrade gRPC without bumping grpc-gateway to v2. However, upgrading grpc-gateway seems like a good vessel for ripping of the FUD we have around mixing gogoproto and google.golang.org/protobuf. We should do it to avoid running into thorny dep issues during routine upgrades.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link

blathers-crl bot commented Nov 12, 2024

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

tbg added 15 commits November 13, 2024 10:22
from v1.56.3 to v1.68.0.

TODO: changelog
Similar but different error:

```
link: package conflict error: google.golang.org/genproto/googleapis/cloud/location: package imports google.golang.org/genproto/googleapis/api/annotations
	  was compiled with: @org_golang_google_genproto//googleapis/api/annotations:annotations
	but was linked with: @org_golang_google_genproto_googleapis_api//annotations:annotations
```

Compare with the original:

```
link: package conflict error: cloud.google.com/go/pubsub/apiv1/pubsubpb: package imports google.golang.org/genproto/googleapis/api/annotations
	  was compiled with: @org_golang_google_genproto_googleapis_api//annotations:annotations
	but was linked with: @org_golang_google_genproto//googleapis/api/annotations:annotations
```
Error unchanged from last commit. I did remember to `./dev gen bazel`.

```
link: package conflict error: google.golang.org/genproto/googleapis/cloud/location: package imports google.golang.org/genproto/googleapis/api/annotations
          was compiled with: @org_golang_google_genproto//googleapis/api/annotations:annotations
        but was linked with: @org_golang_google_genproto_googleapis_api//annotations:annotations
```
…f68ea54

See googleapis/go-genproto#1015.

Sadly grpc-gateway is incompatible with this version of `genproto`:

```
ERROR: no such package '@@org_golang_google_genproto//googleapis/api/httpbody': BUILD file not found in directory 'googleapis/api/httpbody' of external repository @@org_golang_google_genproto. Add a BUILD file to a directory to mark it as a package.
ERROR: /private/var/tmp/_bazel_tbg/b1346cddcc70d57afdaa90f7f09f9b2c/external/com_github_grpc_ecosystem_grpc_gateway/runtime/BUILD.bazel:5:11: no such package '@@org_golang_google_genproto//googleapis/api/httpbody': BUILD file not found in directory 'googleapis/api/httpbody' of external repository @@org_golang_google_genproto. Add a BUILD file to a directory to mark it as a package. and referenced by '@@com_github_grpc_ecosystem_grpc_gateway//runtime:go_default_library'
```

Since we are on the final `grpc-gateway/v1` version already[^1], we'll
have to make the leap to v2 to fix this.

[^1]: https://github.com/grpc-ecosystem/grpc-gateway/releases/tag/v1.16.0
This won't compile but it's fine, just gets this change out of the way.
```
ERROR: /private/var/tmp/_bazel_tbg/b1346cddcc70d57afdaa90f7f09f9b2c/external/com_github_grpc_ecosystem_grpc_gateway_v2/runtime/BUILD.bazel: no such target '@@com_github_grpc_ecosystem_grpc_gateway_v2//runtime:runtime': target 'runtime' not declared in package 'runtime' defined by /private/var/tmp/_bazel_tbg/b1346cddcc70d57afdaa90f7f09f9b2c/external/com_github_grpc_ecosystem_grpc_gateway_v2/runtime/BUILD.bazel
ERROR: /Users/tbg/go/src/github.com/cockroachdb/cockroach/pkg/util/protoutil/BUILD.bazel:5:11: no such target '@@com_github_grpc_ecosystem_grpc_gateway_v2//runtime:runtime': target 'runtime' not declared in package 'runtime' defined by /private/var/tmp/_bazel_tbg/b1346cddcc70d57afdaa90f7f09f9b2c/external/com_github_grpc_ecosystem_grpc_gateway_v2/runtime/BUILD.bazel and referenced by '//pkg/util/protoutil:protoutil'
```
Now we get:

```
ERROR: /private/var/tmp/_bazel_tbg/b1346cddcc70d57afdaa90f7f09f9b2c/external/go_googleapis/google/api/BUILD.bazel: no such target '@@go_googleapis//google/api:httpbody_go_proto': target 'httpbody_go_proto' not declared in package 'google/api' defined by /private/var/tmp/_bazel_tbg/b1346cddcc70d57afdaa90f7f09f9b2c/external/go_googleapis/google/api/BUILD.bazel (did you mean httpbody_proto, or httpbody.proto?)
ERROR: /private/var/tmp/_bazel_tbg/b1346cddcc70d57afdaa90f7f09f9b2c/external/com_github_grpc_ecosystem_grpc_gateway_v2/runtime/BUILD.bazel:5:11: no such target '@@go_googleapis//google/api:httpbody_go_proto': target 'httpbody_go_proto' not declared in package 'google/api' defined by /private/var/tmp/_bazel_tbg/b1346cddcc70d57afdaa90f7f09f9b2c/external/go_googleapis/google/api/BUILD.bazel (did you mean httpbody_proto, or httpbody.proto?) and referenced by '@@com_github_grpc_ecosystem_grpc_gateway_v2//runtime:go_default_library'
```
Error after this:

```
/external/com_github_grpc_ecosystem_grpc_gateway_v2/internal/descriptor/apiconfig/BUILD.bazel:7:14:
no such package '@@googleapis//google/api':
The repository '@@googleapis' could not be resolved: Repository '@@googleapis' is not defined and referenced by '@@com_github_grpc_ecosystem_grpc_gateway_v2//internal/descriptor/apiconfig:apiconfig_proto'
```

I added a .patch trying to fix this (see this commit) but it didn't seem
to take effect.
@tbg tbg added the o-perf-efficiency Related to performance efficiency label Nov 13, 2024
@tbg tbg changed the title go.mod: upgrade gRPC to grpc v1.68.0 go.mod: upgrade grpc-gateway to v2 Nov 27, 2024
Epic: none
Release note: None
@tbg
Copy link
Member Author

tbg commented Dec 3, 2024

https://cockroachlabs.slack.com/archives/CJ0H8Q97C/p1733177280312459?thread_ts=1731420942.261169&cid=CJ0H8Q97C is the latest on how to get something that at least fails at compile time.

@tbg tbg closed this Jan 14, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
o-perf-efficiency Related to performance efficiency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants