Skip to content

Commit

Permalink
api: strip gogoproto annotations (#8163)
Browse files Browse the repository at this point in the history
Remove gogoproto annotations. They can be replaced with a custom gogoproto compiler (e.g. something like https://github.com/gogo/googleapis/tree/master/protoc-gen-gogogoogleapis). I have an experimental version of it to validate that it's possible to re-apply important annotations in the compiler.

Risk Level: low
Testing: builds

Signed-off-by: Kuat Yessenov <[email protected]>
  • Loading branch information
kyessenov authored and htuch committed Sep 6, 2019
1 parent 22e4827 commit e7f0b71
Show file tree
Hide file tree
Showing 106 changed files with 121 additions and 494 deletions.
4 changes: 0 additions & 4 deletions api/bazel/api_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ _COMMON_PROTO_DEPS = [
"@com_google_googleapis//google/api:http_proto",
"@com_google_googleapis//google/api:annotations_proto",
"@com_google_googleapis//google/rpc:status_proto",
"@com_github_gogo_protobuf//:gogo_proto",
"@com_envoyproxy_protoc_gen_validate//validate:validate_proto",
]

Expand Down Expand Up @@ -50,7 +49,6 @@ def api_py_proto_library(name, srcs = [], deps = [], external_py_proto_deps = []
"@com_google_googleapis//google/api:annotations_py_proto",
"@com_google_googleapis//google/api:http_py_proto",
"@com_google_googleapis//google/api:httpbody_py_proto",
"@com_github_gogo_protobuf//:gogo_proto_py",
],
visibility = ["//visibility:public"],
)
Expand Down Expand Up @@ -108,7 +106,6 @@ def api_proto_library(
name = _Suffix(name, _CC_SUFFIX),
linkstatic = linkstatic,
cc_deps = [_LibrarySuffix(d, _CC_SUFFIX) for d in deps] + external_cc_proto_deps + [
"@com_github_gogo_protobuf//:gogo_proto_cc",
"@com_google_googleapis//google/api:http_cc_proto",
"@com_google_googleapis//google/api:annotations_cc_proto",
"@com_google_googleapis//google/rpc:status_cc_proto",
Expand Down Expand Up @@ -180,7 +177,6 @@ def api_proto_package(name = "pkg", srcs = [], deps = [], has_services = False,
proto = name,
visibility = ["//visibility:public"],
deps = [go_proto_mapping(dep) for dep in deps] + [
"@com_github_gogo_protobuf//:gogo_proto_go",
"@com_github_golang_protobuf//ptypes:go_default_library",
"@com_github_golang_protobuf//ptypes/any:go_default_library",
"@com_github_golang_protobuf//ptypes/duration:go_default_library",
Expand Down
61 changes: 1 addition & 60 deletions api/bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ def api_dependencies():
name = "com_github_cncf_udpa",
locations = REPOSITORY_LOCATIONS,
)
envoy_http_archive(
name = "com_github_gogo_protobuf",
locations = REPOSITORY_LOCATIONS,
build_file_content = GOGOPROTO_BUILD_CONTENT,
)

envoy_http_archive(
name = "prometheus_metrics_model",
locations = REPOSITORY_LOCATIONS,
Expand All @@ -44,61 +40,6 @@ def api_dependencies():
build_file_content = ZIPKINAPI_BUILD_CONTENT,
)

GOGOPROTO_BUILD_CONTENT = """
load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "gogo_proto",
srcs = [
"gogoproto/gogo.proto",
],
deps = [
"@com_google_protobuf//:descriptor_proto",
],
visibility = ["//visibility:public"],
)
go_proto_library(
name = "descriptor_go_proto",
importpath = "github.com/golang/protobuf/protoc-gen-go/descriptor",
proto = "@com_google_protobuf//:descriptor_proto",
visibility = ["//visibility:public"],
)
cc_proto_library(
name = "gogo_proto_cc",
srcs = [
"gogoproto/gogo.proto",
],
default_runtime = "@com_google_protobuf//:protobuf",
protoc = "@com_google_protobuf//:protoc",
deps = ["@com_google_protobuf//:cc_wkt_protos"],
visibility = ["//visibility:public"],
)
go_proto_library(
name = "gogo_proto_go",
importpath = "gogoproto",
proto = ":gogo_proto",
visibility = ["//visibility:public"],
deps = [
":descriptor_go_proto",
],
)
py_proto_library(
name = "gogo_proto_py",
srcs = [
"gogoproto/gogo.proto",
],
default_runtime = "@com_google_protobuf//:protobuf_python",
protoc = "@com_google_protobuf//:protoc",
visibility = ["//visibility:public"],
deps = ["@com_google_protobuf//:protobuf_python"],
)
"""

PROMETHEUSMETRICS_BUILD_CONTENT = """
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
Expand Down
8 changes: 0 additions & 8 deletions api/bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
BAZEL_SKYLIB_RELEASE = "0.8.0"
BAZEL_SKYLIB_SHA256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e"

GOGOPROTO_RELEASE = "1.2.1"
GOGOPROTO_SHA256 = "99e423905ba8921e86817607a5294ffeedb66fdd4a85efce5eb2848f715fdb3a"

OPENCENSUS_PROTO_GIT_SHA = "5cec5ea58c3efa81fa808f2bd38ce182da9ee731" # Jul 25, 2019
OPENCENSUS_PROTO_SHA256 = "faeb93f293ff715b0cb530d273901c0e2e99277b9ed1c0a0326bca9ec5774ad2"

Expand Down Expand Up @@ -45,11 +42,6 @@ REPOSITORY_LOCATIONS = dict(
strip_prefix = "udpa-" + UDPA_GIT_SHA,
urls = ["https://github.com/cncf/udpa/archive/" + UDPA_GIT_SHA + ".tar.gz"],
),
com_github_gogo_protobuf = dict(
sha256 = GOGOPROTO_SHA256,
strip_prefix = "protobuf-" + GOGOPROTO_RELEASE,
urls = ["https://github.com/gogo/protobuf/archive/v" + GOGOPROTO_RELEASE + ".tar.gz"],
),
prometheus_metrics_model = dict(
sha256 = PROMETHEUS_SHA,
strip_prefix = "client_model-" + PROMETHEUS_GIT_SHA,
Expand Down
2 changes: 0 additions & 2 deletions api/envoy/admin/v2alpha/config_dump.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import "envoy/config/bootstrap/v2/bootstrap.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";

import "gogoproto/gogo.proto";

// [#protodoc-title: ConfigDump]

// The :ref:`/config_dump <operations_admin_interface_config_dump>` admin endpoint uses this wrapper
Expand Down
2 changes: 0 additions & 2 deletions api/envoy/admin/v3alpha/config_dump.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import "envoy/config/bootstrap/v3alpha/bootstrap.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";

import "gogoproto/gogo.proto";

// [#protodoc-title: ConfigDump]

// The :ref:`/config_dump <operations_admin_interface_config_dump>` admin endpoint uses this wrapper
Expand Down
3 changes: 0 additions & 3 deletions api/envoy/api/v2/auth/cert.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import "google/protobuf/struct.proto";
import "google/protobuf/wrappers.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: Common TLS configuration]

Expand Down
13 changes: 3 additions & 10 deletions api/envoy/api/v2/cds.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ import "google/protobuf/struct.proto";
import "google/protobuf/wrappers.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;
option (gogoproto.stable_marshaler_all) = true;

// Return list of all clusters this proxy will load balance to.
service ClusterDiscoveryService {
Expand Down Expand Up @@ -127,8 +123,7 @@ message Cluster {
EdsClusterConfig eds_cluster_config = 3;

// The timeout for new network connections to hosts in the cluster.
google.protobuf.Duration connect_timeout = 4
[(validate.rules).duration.gt = {}, (gogoproto.stdduration) = true];
google.protobuf.Duration connect_timeout = 4 [(validate.rules).duration.gt = {}];

// Soft limit on size of the cluster’s connections read and write buffers. If
// unspecified, an implementation defined default is applied (1MiB).
Expand Down Expand Up @@ -281,8 +276,7 @@ message Cluster {
// :ref:`STRICT_DNS<envoy_api_enum_value_Cluster.DiscoveryType.STRICT_DNS>`
// and :ref:`LOGICAL_DNS<envoy_api_enum_value_Cluster.DiscoveryType.LOGICAL_DNS>`
// this setting is ignored.
google.protobuf.Duration dns_refresh_rate = 16
[(validate.rules).duration.gt = {}, (gogoproto.stdduration) = true];
google.protobuf.Duration dns_refresh_rate = 16 [(validate.rules).duration.gt = {}];

// Optional configuration for setting cluster's DNS refresh rate. If the value is set to true,
// cluster's DNS refresh rate will be set to resource record's TTL which comes from DNS
Expand Down Expand Up @@ -340,8 +334,7 @@ message Cluster {
// value defaults to 5000ms. For cluster types other than
// :ref:`ORIGINAL_DST<envoy_api_enum_value_Cluster.DiscoveryType.ORIGINAL_DST>`
// this setting is ignored.
google.protobuf.Duration cleanup_interval = 20
[(validate.rules).duration.gt = {}, (gogoproto.stdduration) = true];
google.protobuf.Duration cleanup_interval = 20 [(validate.rules).duration.gt = {}];

// Optional configuration used to bind newly established upstream connections.
// This overrides any bind_config specified in the bootstrap proto.
Expand Down
4 changes: 0 additions & 4 deletions api/envoy/api/v2/cluster/circuit_breaker.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import "envoy/api/v2/core/base.proto";

import "google/protobuf/wrappers.proto";

import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: Circuit breakers]

// :ref:`Circuit breaking<arch_overview_circuit_break>` settings can be
Expand Down
3 changes: 0 additions & 3 deletions api/envoy/api/v2/cluster/filter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ option ruby_package = "Envoy.Api.V2.ClusterNS";
import "google/protobuf/any.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: Upstream filters]
//
Expand Down
3 changes: 0 additions & 3 deletions api/envoy/api/v2/cluster/outlier_detection.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import "google/protobuf/duration.proto";
import "google/protobuf/wrappers.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: Outlier detection]

Expand Down
4 changes: 0 additions & 4 deletions api/envoy/api/v2/core/address.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import "envoy/api/v2/core/base.proto";
import "google/protobuf/wrappers.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: Network addresses]

Expand All @@ -27,7 +24,6 @@ message Pipe {

message SocketAddress {
enum Protocol {
option (gogoproto.goproto_enum_prefix) = false;
TCP = 0;
// [#not-implemented-hide:]
UDP = 1;
Expand Down
6 changes: 0 additions & 6 deletions api/envoy/api/v2/core/base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ import "google/protobuf/struct.proto";
import "google/protobuf/wrappers.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

import "envoy/type/percent.proto";

option (gogoproto.equal_all) = true;
option (gogoproto.stable_marshaler_all) = true;

// [#protodoc-title: Common types]

// Identifies location of where either Envoy runs or where upstream hosts run.
Expand Down Expand Up @@ -131,7 +127,6 @@ enum RoutingPriority {

// HTTP request method.
enum RequestMethod {
option (gogoproto.goproto_enum_prefix) = false;
METHOD_UNSPECIFIED = 0;
GET = 1;
HEAD = 2;
Expand Down Expand Up @@ -247,7 +242,6 @@ message SocketOption {
bytes buf_value = 5;
}
enum SocketState {
option (gogoproto.goproto_enum_prefix) = false;
// Socket options are applied after socket creation but before binding the socket to a port
STATE_PREBIND = 0;
// Socket options are applied after binding the socket to a port but before calling listen()
Expand Down
8 changes: 2 additions & 6 deletions api/envoy/api/v2/core/config_source.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import "google/protobuf/duration.proto";
import "google/protobuf/wrappers.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: Configuration sources]

Expand Down Expand Up @@ -56,11 +53,10 @@ message ApiConfigSource {
repeated GrpcService grpc_services = 4;

// For REST APIs, the delay between successive polls.
google.protobuf.Duration refresh_delay = 3 [(gogoproto.stdduration) = true];
google.protobuf.Duration refresh_delay = 3;

// For REST APIs, the request timeout. If not set, a default value of 1s will be used.
google.protobuf.Duration request_timeout = 5
[(validate.rules).duration.gt.seconds = 0, (gogoproto.stdduration) = true];
google.protobuf.Duration request_timeout = 5 [(validate.rules).duration.gt.seconds = 0];

// For GRPC APIs, the rate limit settings. If present, discovery requests made by Envoy will be
// rate limited.
Expand Down
3 changes: 0 additions & 3 deletions api/envoy/api/v2/core/grpc_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import "google/protobuf/struct.proto";
import "google/protobuf/empty.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: gRPC services]

Expand Down
25 changes: 8 additions & 17 deletions api/envoy/api/v2/core/health_check.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ import "google/protobuf/struct.proto";
import "google/protobuf/wrappers.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: Health check]
// * Health checking :ref:`architecture overview <arch_overview_health_checking>`.
Expand All @@ -27,22 +24,16 @@ option (gogoproto.equal_all) = true;
message HealthCheck {
// The time to wait for a health check response. If the timeout is reached the
// health check attempt will be considered a failure.
google.protobuf.Duration timeout = 1 [
(validate.rules).duration = {
required: true,
gt: {seconds: 0}
},
(gogoproto.stdduration) = true
];
google.protobuf.Duration timeout = 1 [(validate.rules).duration = {
required: true,
gt: {seconds: 0}
}];

// The interval between health checks.
google.protobuf.Duration interval = 2 [
(validate.rules).duration = {
required: true,
gt: {seconds: 0}
},
(gogoproto.stdduration) = true
];
google.protobuf.Duration interval = 2 [(validate.rules).duration = {
required: true,
gt: {seconds: 0}
}];

// An optional jitter amount in milliseconds. If specified, Envoy will start health
// checking after for a random time in ms between 0 and initial_jitter. This only
Expand Down
10 changes: 2 additions & 8 deletions api/envoy/api/v2/core/http_uri.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ option java_multiple_files = true;
option java_package = "io.envoyproxy.envoy.api.v2.core";

import "google/protobuf/duration.proto";
import "gogoproto/gogo.proto";

import "validate/validate.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: HTTP Service URI ]

// Envoy external URI descriptor
Expand Down Expand Up @@ -46,9 +43,6 @@ message HttpUri {
}

// Sets the maximum duration in milliseconds that a response can take to arrive upon request.
google.protobuf.Duration timeout = 3 [
(validate.rules).duration.gte = {},
(validate.rules).duration.required = true,
(gogoproto.stdduration) = true
];
google.protobuf.Duration timeout = 3
[(validate.rules).duration.gte = {}, (validate.rules).duration.required = true];
}
5 changes: 1 addition & 4 deletions api/envoy/api/v2/core/protocol.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import "google/protobuf/duration.proto";
import "google/protobuf/wrappers.proto";

import "validate/validate.proto";
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;

// [#protodoc-title: Protocol options]

Expand All @@ -27,7 +24,7 @@ message HttpProtocolOptions {
// period in which there are no active requests. If not set, there is no idle timeout. When the
// idle timeout is reached the connection will be closed. Note that request based timeouts mean
// that HTTP/2 PINGs will not keep the connection alive.
google.protobuf.Duration idle_timeout = 1 [(gogoproto.stdduration) = true];
google.protobuf.Duration idle_timeout = 1;
}

message Http1ProtocolOptions {
Expand Down
Loading

0 comments on commit e7f0b71

Please sign in to comment.