Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

config: distinct resource/transport API versions. #9526

Merged
merged 23 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions api/envoy/api/v2/core/config_source.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,24 @@ option java_multiple_files = true;

// [#protodoc-title: Configuration sources]

// xDS API version. This is used to describe both resource and transport
// protocol versions (in distinct configuration fields).
enum ApiVersion {
// When not specified, we assume v2, to ease migration to Envoy's stable API
// versioning. If a client does not support v2 (e.g. due to deprecation), this
// is an invalid value.
AUTO = 0;

// Use xDS v2 API.
V2 = 1;

// Use xDS v3alpha API.
V3ALPHA = 2;
}
htuch marked this conversation as resolved.
Show resolved Hide resolved

// API configuration source. This identifies the API type and cluster that Envoy
// will use to fetch an xDS API.
// [#next-free-field: 8]
// [#next-free-field: 9]
message ApiConfigSource {
// APIs may be fetched via either REST or gRPC.
enum ApiType {
Expand All @@ -43,8 +58,13 @@ message ApiConfigSource {
DELTA_GRPC = 3;
}

// API type (gRPC, REST, delta gRPC)
ApiType api_type = 1 [(validate.rules).enum = {defined_only: true}];

// API version for xDS transport protocol. This describes the xDS gRPC/REST
// endpoint and version of [Delta]DiscoveryRequest/Response used on the wire.
ApiVersion transport_api_version = 8 [(validate.rules).enum = {defined_only: true}];

// Cluster names should be used only with REST. If > 1
// cluster is defined, clusters will be cycled through if any kind of failure
// occurs.
Expand Down Expand Up @@ -105,18 +125,6 @@ message RateLimitSettings {
// inotify for updates.
// [#next-free-field: 7]
message ConfigSource {
enum XdsApiVersion {
// use for describing explicitly that xDS API version is set automatically. In default, xDS API
// version is V2
AUTO = 0;

// use xDS v2 API
V2 = 1;

// use xDS v3alpha API
V3ALPHA = 2;
}

oneof config_source_specifier {
option (validate.required) = true;

Expand Down Expand Up @@ -163,6 +171,8 @@ message ConfigSource {
// timeout applies). The default is 15s.
google.protobuf.Duration initial_fetch_timeout = 4;

// API version for xDS endpoint
XdsApiVersion xds_api_version = 6;
// API version for xDS resources. This implies the type URLs that the client
// will request for resources and the resource type that the client will in
// turn expect to be delivered.
ApiVersion resource_api_version = 6 [(validate.rules).enum = {defined_only: true}];
}
40 changes: 25 additions & 15 deletions api/envoy/api/v3alpha/core/config_source.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,24 @@ option java_multiple_files = true;

// [#protodoc-title: Configuration sources]

// xDS API version. This is used to describe both resource and transport
// protocol versions (in distinct configuration fields).
enum ApiVersion {
// When not specified, we assume v2, to ease migration to Envoy's stable API
// versioning. If a client does not support v2 (e.g. due to deprecation), this
// is an invalid value.
AUTO = 0;

// Use xDS v2 API.
V2 = 1;

// Use xDS v3alpha API.
V3ALPHA = 2;
}

// API configuration source. This identifies the API type and cluster that Envoy
// will use to fetch an xDS API.
// [#next-free-field: 8]
// [#next-free-field: 9]
message ApiConfigSource {
option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.core.ApiConfigSource";

Expand Down Expand Up @@ -47,8 +62,13 @@ message ApiConfigSource {
DELTA_GRPC = 3;
}

// API type (gRPC, REST, delta gRPC)
ApiType api_type = 1 [(validate.rules).enum = {defined_only: true}];

// API version for xDS transport protocol. This describes the xDS gRPC/REST
// endpoint and version of [Delta]DiscoveryRequest/Response used on the wire.
ApiVersion transport_api_version = 8 [(validate.rules).enum = {defined_only: true}];

// Cluster names should be used only with REST. If > 1
// cluster is defined, clusters will be cycled through if any kind of failure
// occurs.
Expand Down Expand Up @@ -117,18 +137,6 @@ message RateLimitSettings {
message ConfigSource {
option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.core.ConfigSource";

enum XdsApiVersion {
// use for describing explicitly that xDS API version is set automatically. In default, xDS API
// version is V2
AUTO = 0;

// use xDS v2 API
V2 = 1;

// use xDS v3alpha API
V3ALPHA = 2;
}

oneof config_source_specifier {
option (validate.required) = true;

Expand Down Expand Up @@ -175,6 +183,8 @@ message ConfigSource {
// timeout applies). The default is 15s.
google.protobuf.Duration initial_fetch_timeout = 4;

// API version for xDS endpoint
XdsApiVersion xds_api_version = 6;
// API version for xDS resources. This implies the type URLs that the client
// will request for resources and the resource type that the client will in
// turn expect to be delivered.
ApiVersion resource_api_version = 6 [(validate.rules).enum = {defined_only: true}];
}
40 changes: 25 additions & 15 deletions generated_api_shadow/envoy/api/v2/core/config_source.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion generated_api_shadow/envoy/api/v2/core/grpc_service.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 25 additions & 15 deletions generated_api_shadow/envoy/api/v3alpha/core/config_source.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions source/common/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ envoy_cc_library(
srcs = ["delta_subscription_impl.cc"],
hdrs = ["delta_subscription_impl.h"],
deps = [
":api_version_lib",
":grpc_stream_lib",
":new_grpc_mux_lib",
":utility_lib",
Expand Down Expand Up @@ -136,6 +137,7 @@ envoy_cc_library(
srcs = ["grpc_mux_impl.cc"],
hdrs = ["grpc_mux_impl.h"],
deps = [
":api_version_lib",
":grpc_stream_lib",
":utility_lib",
"//include/envoy/config:grpc_mux_interface",
Expand Down Expand Up @@ -197,6 +199,7 @@ envoy_cc_library(
"http_api_protos",
],
deps = [
":api_version_lib",
"//include/envoy/config:subscription_interface",
"//include/envoy/event:dispatcher_interface",
"//source/common/buffer:buffer_lib",
Expand Down Expand Up @@ -299,8 +302,14 @@ envoy_cc_library(
"//source/common/protobuf",
"@envoy_api//envoy/api/v2:pkg_cc_proto",
"@envoy_api//envoy/api/v2/auth:pkg_cc_proto",
"@envoy_api//envoy/api/v2/core:pkg_cc_proto",
"@envoy_api//envoy/api/v2/route:pkg_cc_proto",
"@envoy_api//envoy/api/v3alpha:pkg_cc_proto",
"@envoy_api//envoy/api/v3alpha/auth:pkg_cc_proto",
"@envoy_api//envoy/api/v3alpha/route:pkg_cc_proto",
"@envoy_api//envoy/service/discovery/v2:pkg_cc_proto",
"@envoy_api//envoy/service/discovery/v3alpha:pkg_cc_proto",
"@envoy_api//envoy/service/route/v3alpha:pkg_cc_proto",
],
)

Expand Down
8 changes: 5 additions & 3 deletions source/common/config/grpc_mux_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "common/common/cleanup.h"
#include "common/common/logger.h"
#include "common/config/api_version.h"
#include "common/config/grpc_stream.h"
#include "common/config/utility.h"

Expand Down Expand Up @@ -59,7 +60,7 @@ class GrpcMuxImpl : public GrpcMux,
void onDiscoveryResponse(std::unique_ptr<envoy::api::v2::DiscoveryResponse>&& message) override;
void onWriteable() override;

GrpcStream<envoy::api::v2::DiscoveryRequest, envoy::api::v2::DiscoveryResponse>&
GrpcStream<API_NO_BOOST(envoy::api::v2::DiscoveryRequest), envoy::api::v2::DiscoveryResponse>&
grpcStreamForTest() {
return grpc_stream_;
}
Expand Down Expand Up @@ -102,7 +103,7 @@ class GrpcMuxImpl : public GrpcMux,
// Watches on the returned resources for the API;
std::list<GrpcMuxWatchImpl*> watches_;
// Current DiscoveryRequest for API.
envoy::api::v2::DiscoveryRequest request_;
API_NO_BOOST(envoy::api::v2::DiscoveryRequest) request_;
// Paused via pause()?
bool paused_{};
// Was a DiscoveryRequest elided during a pause?
Expand All @@ -115,7 +116,8 @@ class GrpcMuxImpl : public GrpcMux,
void queueDiscoveryRequest(const std::string& queue_item);
void clearRequestQueue();

GrpcStream<envoy::api::v2::DiscoveryRequest, envoy::api::v2::DiscoveryResponse> grpc_stream_;
GrpcStream<API_NO_BOOST(envoy::api::v2::DiscoveryRequest), envoy::api::v2::DiscoveryResponse>
grpc_stream_;
const LocalInfo::LocalInfo& local_info_;
const bool skip_subsequent_node_;
bool first_stream_request_;
Expand Down
3 changes: 2 additions & 1 deletion source/common/config/http_subscription_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ HttpSubscriptionImpl::HttpSubscriptionImpl(
const std::string& remote_cluster_name, Event::Dispatcher& dispatcher,
Runtime::RandomGenerator& random, std::chrono::milliseconds refresh_interval,
std::chrono::milliseconds request_timeout, const Protobuf::MethodDescriptor& service_method,
SubscriptionCallbacks& callbacks, SubscriptionStats stats,
absl::string_view type_url, SubscriptionCallbacks& callbacks, SubscriptionStats stats,
std::chrono::milliseconds init_fetch_timeout,
ProtobufMessage::ValidationVisitor& validation_visitor)
: Http::RestApiFetcher(cm, remote_cluster_name, dispatcher, random, refresh_interval,
request_timeout),
callbacks_(callbacks), stats_(stats), dispatcher_(dispatcher),
init_fetch_timeout_(init_fetch_timeout), validation_visitor_(validation_visitor) {
request_.mutable_node()->CopyFrom(local_info.node());
request_.set_type_url(std::string(type_url));
ASSERT(service_method.options().HasExtension(google::api::http));
const auto& http_rule = service_method.options().GetExtension(google::api::http);
path_ = http_rule.post();
Expand Down
Loading