[cabe] update cabe proto targets to support envoy grpc-json transcoding
This CL by itself doesn't do anything interesting yet.
I have a separate WIP CL to update envoy settings in //k8s-config/skfe which will have to land separately since it's in a different repo.
That k8s-config change configures envoy to use the cabe_descriptor_set.pb file generated by the new proto_descriptor_set target in this CL.
See https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/grpc_json_transcoder_filter for envoy's docs on this transcoding feature. TL;DR is you can apply this filter in front of a grpc service, and envoy will transparently switch between REST+JSON and gRPC transport and encodings based on request headers - the service implementation can keep believing that it's always talking gRPC.
Bug: chromium:1473744
Change-Id: Ibe44188f94479e1abe5e40a9fdccbeb05227b478
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/746138
Commit-Queue: Sean McCullough <seanmccullough@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
diff --git a/WORKSPACE b/WORKSPACE
index f8ed914..adf93ae 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -127,6 +127,15 @@
protobuf_deps()
+http_archive(
+ name = "com_google_googleapis",
+ sha256 = "38701e513aff81c89f0f727e925bf04ac4883913d03a60cdebb2c2a5f10beb40",
+ strip_prefix = "googleapis-86fa44cc5ee2136e87c312f153113d4dd8e9c4de",
+ urls = [
+ "https://github.com/googleapis/googleapis/archive/86fa44cc5ee2136e87c312f153113d4dd8e9c4de.tar.gz",
+ ],
+)
+
# Needed by @com_github_bazelbuild_remote_apis for the googleapis protos.
http_archive(
name = "googleapis",
@@ -140,6 +149,14 @@
),
)
+load("@com_google_googleapis//:repository_rules.bzl", googleapis_imports_switched_rules_by_language = "switched_rules_by_language")
+
+googleapis_imports_switched_rules_by_language(
+ name = "com_google_googleapis_imports",
+ go = True,
+ grpc = True,
+)
+
# Needed by @com_github_bazelbuild_remote_apis for gRPC.
http_archive(
name = "com_github_grpc_grpc",
diff --git a/bazel/tools/protoc/BUILD.bazel b/bazel/tools/protoc/BUILD.bazel
index 2d2664d..83c6b3c 100644
--- a/bazel/tools/protoc/BUILD.bazel
+++ b/bazel/tools/protoc/BUILD.bazel
@@ -85,6 +85,7 @@
"@com_github_twitchtv_twirp//protoc-gen-twirp",
"@org_golang_google_protobuf//cmd/protoc-gen-go",
"@org_golang_google_grpc_cmd_protoc_gen_go_grpc//:protoc-gen-go-grpc",
+ "@com_google_googleapis//google/api:annotations_proto",
],
visibility = ["//visibility:public"],
)
diff --git a/cabe/go/proto/BUILD.bazel b/cabe/go/proto/BUILD.bazel
index 7185139..97fb07d 100644
--- a/cabe/go/proto/BUILD.bazel
+++ b/cabe/go/proto/BUILD.bazel
@@ -12,6 +12,7 @@
importpath = "go.skia.org/infra/cabe/go/proto",
visibility = ["//visibility:public"],
deps = [
+ "@go_googleapis//google/api:annotations_go_proto",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
diff --git a/cabe/go/proto/generate.go b/cabe/go/proto/generate.go
index 055d55d..0675e37 100644
--- a/cabe/go/proto/generate.go
+++ b/cabe/go/proto/generate.go
@@ -1,5 +1,5 @@
// Generate the go code from the protocol buffer definitions.
-//go:generate bazelisk run --config=mayberemote //:protoc -- --go_opt=module=go.skia.org/infra/cabe/go/proto --go_out=. --go-grpc_opt=module=go.skia.org/infra/cabe/go/proto --go-grpc_out=. -I ../../.. cabe/proto/analysis.proto cabe/proto/service.proto cabe/proto/spec.proto
+//go:generate bazelisk run --config=mayberemote //:protoc -- --go_opt=module=go.skia.org/infra/cabe/go/proto --go_out=. --go-grpc_opt=module=go.skia.org/infra/cabe/go/proto --go-grpc_out=. -I ../../.. cabe/proto/analysis.proto cabe/proto/service.proto cabe/proto/spec.proto --descriptor_set_in ../../../_bazel_bin/external/com_google_googleapis/google/api/annotations_proto-descriptor-set.proto.bin:../../../_bazel_bin/external/com_google_googleapis/google/api/http_proto-descriptor-set.proto.bin
//go:generate bazelisk run --config=mayberemote //:goimports "--run_under=cd $PWD &&" -- -w analysis.pb.go
//go:generate bazelisk run --config=mayberemote //:goimports "--run_under=cd $PWD &&" -- -w service.pb.go
//go:generate bazelisk run --config=mayberemote //:goimports "--run_under=cd $PWD &&" -- -w service_grpc.pb.go
diff --git a/cabe/go/proto/service.pb.go b/cabe/go/proto/service.pb.go
index a000cac..35ed800 100644
--- a/cabe/go/proto/service.pb.go
+++ b/cabe/go/proto/service.pb.go
@@ -10,6 +10,7 @@
reflect "reflect"
sync "sync"
+ _ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
@@ -32,9 +33,9 @@
// files. If reality doesn't match the spec, CABE returns an error with
// some information about what didn't match the provided ExperimentSpec.
//
- // If experiment_spec isn't set, CABE will infer one based on hueristics*
+ // If experiment_spec isn't set, CABE will infer one based on heuristics*
// and data available from Swarming and RBE-CAS at the time of the request.
- // Note that this is best-effort and not guarnateed to do what the caller
+ // Note that this is best-effort and not guaranteed to do what the caller
// expects. If you have specific benchmarks and workloads that need to be
// either analyzed or cause errors if they are missing, you should specify an
// explicit experiment_spec value.
@@ -154,37 +155,41 @@
var file_cabe_proto_service_proto_rawDesc = []byte{
0x0a, 0x18, 0x63, 0x61, 0x62, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x63, 0x61, 0x62, 0x65,
- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x61, 0x62, 0x65, 0x2f, 0x70, 0x72, 0x6f,
- 0x74, 0x6f, 0x2f, 0x61, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x1a, 0x15, 0x63, 0x61, 0x62, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x70,
- 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x81, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74,
- 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
- 0x26, 0x0a, 0x0f, 0x70, 0x69, 0x6e, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x6a, 0x6f, 0x62, 0x5f,
- 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x69, 0x6e, 0x70, 0x6f, 0x69,
- 0x6e, 0x74, 0x4a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x43, 0x0a, 0x0f, 0x65, 0x78, 0x70, 0x65, 0x72,
- 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
- 0x32, 0x1a, 0x2e, 0x63, 0x61, 0x62, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x78,
- 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x70, 0x65, 0x63, 0x52, 0x0e, 0x65, 0x78,
- 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x70, 0x65, 0x63, 0x22, 0xa1, 0x01, 0x0a,
- 0x13, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x52, 0x65, 0x73, 0x70,
- 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18,
- 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x61, 0x62, 0x65, 0x2e, 0x70, 0x72, 0x6f,
- 0x74, 0x6f, 0x2e, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c,
- 0x74, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x54, 0x0a, 0x18, 0x69, 0x6e,
- 0x66, 0x65, 0x72, 0x72, 0x65, 0x64, 0x5f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e,
- 0x74, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63,
- 0x61, 0x62, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x78, 0x70, 0x65, 0x72, 0x69,
- 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x70, 0x65, 0x63, 0x52, 0x16, 0x69, 0x6e, 0x66, 0x65, 0x72, 0x72,
- 0x65, 0x64, 0x45, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x70, 0x65, 0x63,
- 0x32, 0x5c, 0x0a, 0x08, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x12, 0x50, 0x0a, 0x0b,
- 0x47, 0x65, 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x12, 0x1e, 0x2e, 0x63, 0x61,
- 0x62, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x61, 0x6c,
- 0x79, 0x73, 0x69, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x63, 0x61,
- 0x62, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x61, 0x6c,
- 0x79, 0x73, 0x69, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x21,
- 0x5a, 0x1f, 0x67, 0x6f, 0x2e, 0x73, 0x6b, 0x69, 0x61, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x69, 0x6e,
- 0x66, 0x72, 0x61, 0x2f, 0x63, 0x61, 0x62, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61,
+ 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x61, 0x62, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x2f, 0x61, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
+ 0x15, 0x63, 0x61, 0x62, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x70, 0x65, 0x63,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x81, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x41, 0x6e,
+ 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a,
+ 0x0f, 0x70, 0x69, 0x6e, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x6a, 0x6f, 0x62, 0x5f, 0x69, 0x64,
+ 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x69, 0x6e, 0x70, 0x6f, 0x69, 0x6e, 0x74,
+ 0x4a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x43, 0x0a, 0x0f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d,
+ 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a,
+ 0x2e, 0x63, 0x61, 0x62, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x78, 0x70, 0x65,
+ 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x70, 0x65, 0x63, 0x52, 0x0e, 0x65, 0x78, 0x70, 0x65,
+ 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x70, 0x65, 0x63, 0x22, 0xa1, 0x01, 0x0a, 0x13, 0x47,
+ 0x65, 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+ 0x73, 0x65, 0x12, 0x34, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20,
+ 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x61, 0x62, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x2e, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52,
+ 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x54, 0x0a, 0x18, 0x69, 0x6e, 0x66, 0x65,
+ 0x72, 0x72, 0x65, 0x64, 0x5f, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x5f,
+ 0x73, 0x70, 0x65, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x61, 0x62,
+ 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65,
+ 0x6e, 0x74, 0x53, 0x70, 0x65, 0x63, 0x52, 0x16, 0x69, 0x6e, 0x66, 0x65, 0x72, 0x72, 0x65, 0x64,
+ 0x45, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x70, 0x65, 0x63, 0x32, 0x84,
+ 0x01, 0x0a, 0x08, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x12, 0x78, 0x0a, 0x0b, 0x47,
+ 0x65, 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x12, 0x1e, 0x2e, 0x63, 0x61, 0x62,
+ 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79,
+ 0x73, 0x69, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x63, 0x61, 0x62,
+ 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79,
+ 0x73, 0x69, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x82, 0xd3, 0xe4,
+ 0x93, 0x02, 0x22, 0x22, 0x20, 0x2f, 0x63, 0x61, 0x62, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x2e, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x73, 0x69, 0x73, 0x2f, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x61,
+ 0x6c, 0x79, 0x73, 0x69, 0x73, 0x42, 0x21, 0x5a, 0x1f, 0x67, 0x6f, 0x2e, 0x73, 0x6b, 0x69, 0x61,
+ 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x2f, 0x63, 0x61, 0x62, 0x65, 0x2f,
+ 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
diff --git a/cabe/proto/BUILD.bazel b/cabe/proto/BUILD.bazel
index 5461c7b..1bb2340 100644
--- a/cabe/proto/BUILD.bazel
+++ b/cabe/proto/BUILD.bazel
@@ -1,4 +1,4 @@
-load("@rules_proto//proto:defs.bzl", "proto_library")
+load("@rules_proto//proto:defs.bzl", "proto_descriptor_set", "proto_library")
proto_library(
name = "spec_proto",
@@ -31,5 +31,18 @@
deps = [
":analysis_proto",
":spec_proto",
+ "@com_google_googleapis//google/api:annotations_proto",
+ ],
+)
+
+# envoy needs this file in order to automatically transcode json/REST requests to gRPC.
+# Ideally, envoy would be able to use reflection to query cabeserver for this information
+# but it cannot currently do this. See the open "gRPC/JSON transcoding using reflection"
+# issue for more context: https://github.com/envoyproxy/envoy/issues/1182
+proto_descriptor_set(
+ name = "cabe_descriptor_set",
+ deps = [
+ ":service_proto",
+ "@com_google_googleapis//google/api:annotations_proto",
],
)
diff --git a/cabe/proto/cabe_descriptor_set.pb b/cabe/proto/cabe_descriptor_set.pb
new file mode 100644
index 0000000..090cbd8
--- /dev/null
+++ b/cabe/proto/cabe_descriptor_set.pb
Binary files differ
diff --git a/cabe/proto/service.proto b/cabe/proto/service.proto
index 5e92e2f..ffba94f 100644
--- a/cabe/proto/service.proto
+++ b/cabe/proto/service.proto
@@ -3,12 +3,16 @@
package cabe.proto;
option go_package = "go.skia.org/infra/cabe/go/proto";
+import "google/api/annotations.proto";
import "cabe/proto/analysis.proto";
import "cabe/proto/spec.proto";
service Analysis {
// Get results of a performance experiment analysis.
rpc GetAnalysis(GetAnalysisRequest) returns (GetAnalysisResponse) {
+ option (google.api.http) = {
+ post: "/cabe.proto.Analysis/GetAnalysis"
+ };
}
}
@@ -20,9 +24,9 @@
// files. If reality doesn't match the spec, CABE returns an error with
// some information about what didn't match the provided ExperimentSpec.
//
- // If experiment_spec isn't set, CABE will infer one based on hueristics*
+ // If experiment_spec isn't set, CABE will infer one based on heuristics*
// and data available from Swarming and RBE-CAS at the time of the request.
- // Note that this is best-effort and not guarnateed to do what the caller
+ // Note that this is best-effort and not guaranteed to do what the caller
// expects. If you have specific benchmarks and workloads that need to be
// either analyzed or cause errors if they are missing, you should specify an
// explicit experiment_spec value.
@@ -41,4 +45,3 @@
// it was able to infer the experiment to this field.
ExperimentSpec inferred_experiment_spec = 2;
}
-