Skip to content

Commit

Permalink
api: protoxform tool and API reformat. (#8309)
Browse files Browse the repository at this point in the history
This patch introduces a new tool, protoxform, that will be the basis of
the v2 -> v3 migration tooling. It operates as a Python protoc plugin,
within the same framework as protodoc, and provides the ability to
operate on protoc AST input and generate proto output.

As a first step, the tool is applied reflexively on v2, and functions as
a formatting tool. In later patches, this will be added to
check_format/fix_format scripts and CI.

Part of #8082.

Risk level: medium (it's possible that some inadvertent wire changes
  occur, if they do, this patch should be rolled back).
Testing: manual inspection of diff, bazel test //test/..., some
  grep/diff scripts to ensure we haven't lost any comments.

Signed-off-by: Harvey Tuch <htuch@google.com>
  • Loading branch information
htuch authored Sep 23, 2019
1 parent 081b0b9 commit 08b123a
Show file tree
Hide file tree
Showing 110 changed files with 2,680 additions and 1,813 deletions.
3 changes: 1 addition & 2 deletions api/envoy/admin/v2alpha/certs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ message Certificates {
}

message Certificate {

// Details of CA certificate.
repeated CertificateDetails ca_cert = 1;

Expand Down Expand Up @@ -48,10 +47,10 @@ message CertificateDetails {
}

message SubjectAlternateName {

// Subject Alternate Name.
oneof name {
string dns = 1;

string uri = 2;
}
}
12 changes: 6 additions & 6 deletions api/envoy/admin/v2alpha/clusters.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ message ClusterStatus {
// 2. The threshold is computed to be < 0 because a negative value implies that there was no
// threshold for that interval.
// 3. Outlier detection is not enabled for this cluster.
envoy.type.Percent success_rate_ejection_threshold = 3;
type.Percent success_rate_ejection_threshold = 3;

// Mapping from host address to the host's current status.
repeated HostStatus host_statuses = 4;
Expand All @@ -65,13 +65,13 @@ message ClusterStatus {
// 2. The threshold is computed to be < 0 because a negative value implies that there was no
// threshold for that interval.
// 3. Outlier detection is not enabled for this cluster.
envoy.type.Percent local_origin_success_rate_ejection_threshold = 5;
type.Percent local_origin_success_rate_ejection_threshold = 5;
}

// Current state of a particular host.
message HostStatus {
// Address of this host.
envoy.api.v2.core.Address address = 1;
api.v2.core.Address address = 1;

// List of stats specific to this host.
repeated SimpleMetric stats = 2;
Expand All @@ -92,7 +92,7 @@ message HostStatus {
// Note: the message will not be present if host did not have enough request volume to calculate
// success rate or the cluster did not have enough hosts to run through success rate outlier
// ejection.
envoy.type.Percent success_rate = 4;
type.Percent success_rate = 4;

// The host's weight. If not configured, the value defaults to 1.
uint32 weight = 5;
Expand All @@ -115,7 +115,7 @@ message HostStatus {
// Note: the message will not be present if host did not have enough request volume to calculate
// success rate or the cluster did not have enough hosts to run through success rate outlier
// ejection.
envoy.type.Percent local_origin_success_rate = 8;
type.Percent local_origin_success_rate = 8;
}

// Health status for a host.
Expand All @@ -139,5 +139,5 @@ message HostHealthStatus {
// Health status as reported by EDS. Note: only HEALTHY and UNHEALTHY are currently supported
// here.
// TODO(mrice32): pipe through remaining EDS health status possibilities.
envoy.api.v2.core.HealthStatus eds_health_status = 3;
api.v2.core.HealthStatus eds_health_status = 3;
}
42 changes: 21 additions & 21 deletions api/envoy/admin/v2alpha/config_dump.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ message ConfigDump {
// the static portions of an Envoy configuration by reusing the output as the bootstrap
// configuration for another Envoy.
message BootstrapConfigDump {
envoy.config.bootstrap.v2.Bootstrap bootstrap = 1;
config.bootstrap.v2.Bootstrap bootstrap = 1;

// The timestamp when the BootstrapConfig was last updated.
google.protobuf.Timestamp last_updated = 2;
Expand All @@ -49,15 +49,10 @@ message BootstrapConfigDump {
// configuration information can be used to recreate an Envoy configuration by populating all
// listeners as static listeners or by returning them in a LDS response.
message ListenersConfigDump {
// This is the :ref:`version_info <envoy_api_field_DiscoveryResponse.version_info>` in the
// last processed LDS discovery response. If there are only static bootstrap listeners, this field
// will be "".
string version_info = 1;

// Describes a statically loaded listener.
message StaticListener {
// The listener config.
envoy.api.v2.Listener listener = 1;
api.v2.Listener listener = 1;

// The timestamp when the Listener was last updated.
google.protobuf.Timestamp last_updated = 2;
Expand All @@ -72,12 +67,17 @@ message ListenersConfigDump {
string version_info = 1;

// The listener config.
envoy.api.v2.Listener listener = 2;
api.v2.Listener listener = 2;

// The timestamp when the Listener was last updated.
google.protobuf.Timestamp last_updated = 3;
}

// This is the :ref:`version_info <envoy_api_field_DiscoveryResponse.version_info>` in the
// last processed LDS discovery response. If there are only static bootstrap listeners, this field
// will be "".
string version_info = 1;

// The statically loaded listener configs.
repeated StaticListener static_listeners = 2;

Expand All @@ -102,15 +102,10 @@ message ListenersConfigDump {
// configuration information can be used to recreate an Envoy configuration by populating all
// clusters as static clusters or by returning them in a CDS response.
message ClustersConfigDump {
// This is the :ref:`version_info <envoy_api_field_DiscoveryResponse.version_info>` in the
// last processed CDS discovery response. If there are only static bootstrap clusters, this field
// will be "".
string version_info = 1;

// Describes a statically loaded cluster.
message StaticCluster {
// The cluster config.
envoy.api.v2.Cluster cluster = 1;
api.v2.Cluster cluster = 1;

// The timestamp when the Cluster was last updated.
google.protobuf.Timestamp last_updated = 2;
Expand All @@ -125,12 +120,17 @@ message ClustersConfigDump {
string version_info = 1;

// The cluster config.
envoy.api.v2.Cluster cluster = 2;
api.v2.Cluster cluster = 2;

// The timestamp when the Cluster was last updated.
google.protobuf.Timestamp last_updated = 3;
}

// This is the :ref:`version_info <envoy_api_field_DiscoveryResponse.version_info>` in the
// last processed CDS discovery response. If there are only static bootstrap clusters, this field
// will be "".
string version_info = 1;

// The statically loaded cluster configs.
repeated StaticCluster static_clusters = 2;

Expand All @@ -153,7 +153,7 @@ message ClustersConfigDump {
message RoutesConfigDump {
message StaticRouteConfig {
// The route config.
envoy.api.v2.RouteConfiguration route_config = 1;
api.v2.RouteConfiguration route_config = 1;

// The timestamp when the Route was last updated.
google.protobuf.Timestamp last_updated = 2;
Expand All @@ -166,7 +166,7 @@ message RoutesConfigDump {
string version_info = 1;

// The route config.
envoy.api.v2.RouteConfiguration route_config = 2;
api.v2.RouteConfiguration route_config = 2;

// The timestamp when the Route was last updated.
google.protobuf.Timestamp last_updated = 3;
Expand All @@ -189,7 +189,7 @@ message ScopedRoutesConfigDump {
string name = 1;

// The scoped route configurations.
repeated envoy.api.v2.ScopedRouteConfiguration scoped_route_configs = 2;
repeated api.v2.ScopedRouteConfiguration scoped_route_configs = 2;

// The timestamp when the scoped route config set was last updated.
google.protobuf.Timestamp last_updated = 3;
Expand All @@ -205,7 +205,7 @@ message ScopedRoutesConfigDump {
string version_info = 2;

// The scoped route configurations.
repeated envoy.api.v2.ScopedRouteConfiguration scoped_route_configs = 3;
repeated api.v2.ScopedRouteConfiguration scoped_route_configs = 3;

// The timestamp when the scoped route config set was last updated.
google.protobuf.Timestamp last_updated = 4;
Expand Down Expand Up @@ -234,7 +234,7 @@ message SecretsConfigDump {
// The actual secret information.
// Security sensitive information is redacted (replaced with "[redacted]") for
// private keys and passwords in TLS certificates.
envoy.api.v2.auth.Secret secret = 4;
api.v2.auth.Secret secret = 4;
}

// StaticSecret specifies statically loaded secret in bootstrap.
Expand All @@ -248,7 +248,7 @@ message SecretsConfigDump {
// The actual secret information.
// Security sensitive information is redacted (replaced with "[redacted]") for
// private keys and passwords in TLS certificates.
envoy.api.v2.auth.Secret secret = 3;
api.v2.auth.Secret secret = 3;
}

// The statically loaded secrets.
Expand Down
2 changes: 1 addition & 1 deletion api/envoy/admin/v2alpha/listeners.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ message ListenerStatus {

// The actual local address that the listener is listening on. If a listener was configured
// to listen on port 0, then this address has the port that was allocated by the OS.
envoy.api.v2.core.Address local_address = 2;
api.v2.core.Address local_address = 2;
}
1 change: 0 additions & 1 deletion api/envoy/admin/v2alpha/memory.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ option java_package = "io.envoyproxy.envoy.admin.v2alpha";
// values extracted from an internal TCMalloc instance. For more information, see the section of the
// docs entitled ["Generic Tcmalloc Status"](https://gperftools.github.io/gperftools/tcmalloc.html).
message Memory {

// The number of bytes allocated by the heap for Envoy. This is an alias for
// `generic.current_allocated_bytes`.
uint64 allocated = 1;
Expand Down
1 change: 1 addition & 0 deletions api/envoy/admin/v2alpha/metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ option java_package = "io.envoyproxy.envoy.admin.v2alpha";
message SimpleMetric {
enum Type {
COUNTER = 0;

GAUGE = 1;
}

Expand Down
1 change: 0 additions & 1 deletion api/envoy/admin/v2alpha/mutex_stats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ option java_package = "io.envoyproxy.envoy.admin.v2alpha";
// correspond to core clock frequency. For more information, see the `CycleClock`
// [docs](https://github.com/abseil/abseil-cpp/blob/master/absl/base/internal/cycleclock.h).
message MutexStats {

// The number of individual mutex contentions which have occurred since startup.
uint64 num_contentions = 1;

Expand Down
47 changes: 26 additions & 21 deletions api/envoy/admin/v2alpha/server_info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ import "google/protobuf/duration.proto";
// Proto representation of the value returned by /server_info, containing
// server version/server status information.
message ServerInfo {
// Server version.
string version = 1;

enum State {
// Server is live and serving traffic.
LIVE = 0;

// Server is draining listeners in response to external health checks failing.
DRAINING = 1;

// Server has not yet completed cluster manager initialization.
PRE_INITIALIZING = 2;

// Server is running the cluster manager initialization callbacks (e.g., RDS).
INITIALIZING = 3;
}

// Server version.
string version = 1;

// State of the server.
State state = 2;

Expand All @@ -44,6 +47,25 @@ message ServerInfo {
}

message CommandLineOptions {
enum IpVersion {
v4 = 0;

v6 = 1;
}

enum Mode {
// Validate configs and then serve traffic normally.
Serve = 0;

// Validate configs and exit.
Validate = 1;

// Completely load and initialize the config, and then exit without running the listener loop.
InitOnly = 2;
}

reserved 12;

// See :option:`--base-id` for details.
uint64 base_id = 1;

Expand All @@ -65,11 +87,6 @@ message CommandLineOptions {
// See :option:`--admin-address-path` for details.
string admin_address_path = 6;

enum IpVersion {
v4 = 0;
v6 = 1;
}

// See :option:`--local-address-ip-version` for details.
IpVersion local_address_ip_version = 7;

Expand All @@ -85,8 +102,6 @@ message CommandLineOptions {
// See :option:`--log-path` for details.
string log_path = 11;

reserved 12;

// See :option:`--service-cluster` for details.
string service_cluster = 13;

Expand All @@ -105,22 +120,12 @@ message CommandLineOptions {
// See :option:`--parent-shutdown-time-s` for details.
google.protobuf.Duration parent_shutdown_time = 18;

enum Mode {
// Validate configs and then serve traffic normally.
Serve = 0;

// Validate configs and exit.
Validate = 1;

// Completely load and initialize the config, and then exit without running the listener loop.
InitOnly = 2;
}

// See :option:`--mode` for details.
Mode mode = 19;

// max_stats and max_obj_name_len are now unused and have no effect.
uint64 max_stats = 20 [deprecated = true];

uint64 max_obj_name_len = 21 [deprecated = true];

// See :option:`--disable-hot-restart` for details.
Expand Down
11 changes: 6 additions & 5 deletions api/envoy/admin/v2alpha/tap.proto
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
syntax = "proto3";

import "envoy/service/tap/v2alpha/common.proto";
import "validate/validate.proto";

package envoy.admin.v2alpha;

option java_outer_classname = "TapProto";
option java_multiple_files = true;
option java_package = "io.envoyproxy.envoy.admin.v2alpha";

import "envoy/service/tap/v2alpha/common.proto";

import "validate/validate.proto";

// The /tap admin request body that is used to configure an active tap session.
message TapRequest {
// The opaque configuration ID used to match the configuration to a loaded extension.
// A tap extension configures a similar opaque ID that is used to match.
string config_id = 1 [(validate.rules).string.min_bytes = 1];
string config_id = 1 [(validate.rules).string = {min_bytes: 1}];

// The tap configuration to load.
service.tap.v2alpha.TapConfig tap_config = 2 [(validate.rules).message.required = true];
service.tap.v2alpha.TapConfig tap_config = 2 [(validate.rules).message = {required: true}];
}
Loading

0 comments on commit 08b123a

Please sign in to comment.