Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into deprecate_v1_config
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Klein <mklein@lyft.com>
  • Loading branch information
mattklein123 committed Jun 5, 2019
2 parents b2b166b + 094496f commit b2222be
Show file tree
Hide file tree
Showing 94 changed files with 1,337 additions and 405 deletions.
9 changes: 5 additions & 4 deletions bazel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,19 +529,20 @@ to run clang-format scripts on your workstation directly:
* It's possible there is a speed advantage
* Docker itself can sometimes go awry and you then have to deal with that
* Type-ahead doesn't always work when waiting running a command through docker

To run the tools directly, you must install the correct version of clang. This
may change over time but as of January 2019,
[clang+llvm-7.0.0](https://releases.llvm.org/download.html) works well. You must
may change over time but as of June 2019,
[clang+llvm-8.0.0](https://releases.llvm.org/download.html) works well. You must
also have 'buildifier' installed from the bazel distribution.

Edit the paths shown here to reflect the installation locations on your system:

```shell
export CLANG_FORMAT="$HOME/ext/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-format"
export CLANG_FORMAT="$HOME/ext/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-format"
export BUILDIFIER_BIN="/usr/bin/buildifier"
```

Once this is set up, you can run clang-tidy without docker:
Once this is set up, you can run clang-format without docker:

```shell
./tools/check_format.py check
Expand Down
16 changes: 8 additions & 8 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ REPOSITORY_LOCATIONS = dict(
),
boringssl = dict(
# Use commits from branch "chromium-stable-with-bazel"
sha256 = "4825306f702fa5cb76fd86c987a88c9bbb241e75f4d86dbb3714530ca73c1fb1",
strip_prefix = "boringssl-8cb07520451f0dc454654f2da5cdecf0b806f823",
# chromium-74.0.3729.131
urls = ["https://github.com/google/boringssl/archive/8cb07520451f0dc454654f2da5cdecf0b806f823.tar.gz"],
sha256 = "448773376d063b1e9a19e4fd41002d1a31a968a13be20b3b66ecd4aab9cf14a8",
strip_prefix = "boringssl-e534d74f5732e1aeebd514f05271d089c530c2f9",
# chromium-75.0.3770.80
urls = ["https://github.com/google/boringssl/archive/e534d74f5732e1aeebd514f05271d089c530c2f9.tar.gz"],
),
boringssl_fips = dict(
sha256 = "b12ad676ee533824f698741bd127f6fbc82c46344398a6d78d25e62c6c418c73",
Expand Down Expand Up @@ -221,10 +221,10 @@ REPOSITORY_LOCATIONS = dict(
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.18.5/rules_go-0.18.5.tar.gz"],
),
rules_foreign_cc = dict(
sha256 = "ccffb49fb24aee3f0a005fa59810dc596228fe86eacacbe0c004d59ed1881bd8",
strip_prefix = "rules_foreign_cc-bf99a0bf0080bcd50431aa7124ef23e5afd58325",
# 2019-05-17
urls = ["https://github.com/bazelbuild/rules_foreign_cc/archive/bf99a0bf0080bcd50431aa7124ef23e5afd58325.tar.gz"],
sha256 = "980c1b74f5c18ea099889b0fb0479ee34b8a02845d3d302ecb16b15d73d624c8",
strip_prefix = "rules_foreign_cc-a0dc109915cea85909bef586e2b2a9bbdc6c8ff5",
# 2019-06-04
urls = ["https://github.com/bazelbuild/rules_foreign_cc/archive/a0dc109915cea85909bef586e2b2a9bbdc6c8ff5.tar.gz"],
),
six_archive = dict(
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
Expand Down
2 changes: 1 addition & 1 deletion docs/root/intro/arch_overview/load_balancing/subsets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ condition described above.

If subsets are :ref:`configured <envoy_api_field_Cluster.lb_subset_config>` and a route
specifies no metadata or no subset matching the metadata exists, the subset load balancer initiates
its fallback policy. The default policy is ``NO_ENDPOINT``, in which case the request fails as if
its fallback policy. The default policy is ``NO_FALLBACK``, in which case the request fails as if
the cluster had no hosts. Conversely, the ``ANY_ENDPOINT`` fallback policy load balances across all
hosts in the cluster, without regard to host metadata. Finally, the ``DEFAULT_SUBSET`` causes
fallback to load balance among hosts that match a specific set of metadata.
Expand Down
4 changes: 1 addition & 3 deletions include/envoy/config/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ class Subscription {
* Start a configuration subscription asynchronously. This should be called once and will continue
* to fetch throughout the lifetime of the Subscription object.
* @param resources set of resource names to fetch.
* @param callbacks the callbacks to be notified of configuration updates. The callback must not
* result in the deletion of the Subscription object.
*/
virtual void start(const std::set<std::string>& resources, SubscriptionCallbacks& callbacks) PURE;
virtual void start(const std::set<std::string>& resource_names) PURE;

/**
* Update the resources to fetch.
Expand Down
5 changes: 5 additions & 0 deletions include/envoy/http/conn_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ class Instance : public Event::DeferredDeletable {
* should be done by resetting the stream.
*/
virtual Cancellable* newStream(Http::StreamDecoder& response_decoder, Callbacks& callbacks) PURE;

/**
* @return Upstream::HostDescriptionConstSharedPtr the host for which connections are pooled.
*/
virtual Upstream::HostDescriptionConstSharedPtr host() const PURE;
};

typedef std::unique_ptr<Instance> InstancePtr;
Expand Down
17 changes: 16 additions & 1 deletion source/common/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ envoy_cc_library(
"@envoy_api//envoy/config/filter/network/client_ssl_auth/v2:client_ssl_auth_cc",
"@envoy_api//envoy/config/filter/network/http_connection_manager/v2:http_connection_manager_cc",
"@envoy_api//envoy/config/filter/network/mongo_proxy/v2:mongo_proxy_cc",
"@envoy_api//envoy/config/filter/network/rate_limit/v2:rate_limit_cc",
"@envoy_api//envoy/config/filter/network/redis_proxy/v2:redis_proxy_cc",
"@envoy_api//envoy/config/filter/network/tcp_proxy/v2:tcp_proxy_cc",
],
Expand Down Expand Up @@ -318,6 +317,7 @@ envoy_cc_library(
":grpc_mux_subscription_lib",
":grpc_subscription_lib",
":http_subscription_lib",
":type_to_endpoint_lib",
":utility_lib",
"//include/envoy/config:subscription_interface",
"//include/envoy/upstream:cluster_manager_interface",
Expand All @@ -338,6 +338,21 @@ envoy_cc_library(
],
)

envoy_cc_library(
name = "type_to_endpoint_lib",
srcs = ["type_to_endpoint.cc"],
hdrs = ["type_to_endpoint.h"],
deps = [
"//source/common/grpc:common_lib",
"//source/common/protobuf",
"@envoy_api//envoy/api/v2:cds_cc",
"@envoy_api//envoy/api/v2:eds_cc",
"@envoy_api//envoy/api/v2:lds_cc",
"@envoy_api//envoy/api/v2:rds_cc",
"@envoy_api//envoy/api/v2:srds_cc",
],
)

envoy_cc_library(
name = "utility_lib",
srcs = ["utility.cc"],
Expand Down
17 changes: 8 additions & 9 deletions source/common/config/delta_subscription_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ DeltaSubscriptionImpl::DeltaSubscriptionImpl(
const LocalInfo::LocalInfo& local_info, Grpc::AsyncClientPtr async_client,
Event::Dispatcher& dispatcher, const Protobuf::MethodDescriptor& service_method,
absl::string_view type_url, Runtime::RandomGenerator& random, Stats::Scope& scope,
const RateLimitSettings& rate_limit_settings, SubscriptionStats stats,
std::chrono::milliseconds init_fetch_timeout)
const RateLimitSettings& rate_limit_settings, SubscriptionCallbacks& callbacks,
SubscriptionStats stats, std::chrono::milliseconds init_fetch_timeout)
: grpc_stream_(this, std::move(async_client), service_method, random, dispatcher, scope,
rate_limit_settings),
type_url_(type_url), local_info_(local_info), stats_(stats), dispatcher_(dispatcher),
init_fetch_timeout_(init_fetch_timeout) {}
type_url_(type_url), local_info_(local_info), callbacks_(callbacks), stats_(stats),
dispatcher_(dispatcher), init_fetch_timeout_(init_fetch_timeout) {}

void DeltaSubscriptionImpl::pause() { state_->pause(); }
void DeltaSubscriptionImpl::resume() {
Expand All @@ -28,12 +28,11 @@ void DeltaSubscriptionImpl::resume() {
}

// Config::Subscription
void DeltaSubscriptionImpl::start(const std::set<std::string>& resources,
SubscriptionCallbacks& callbacks) {
state_ = std::make_unique<DeltaSubscriptionState>(type_url_, resources, callbacks, local_info_,
init_fetch_timeout_, dispatcher_, stats_);
void DeltaSubscriptionImpl::start(const std::set<std::string>& resource_names) {
state_ = std::make_unique<DeltaSubscriptionState>(
type_url_, resource_names, callbacks_, local_info_, init_fetch_timeout_, dispatcher_, stats_);
grpc_stream_.establishNewStream();
updateResources(resources);
updateResources(resource_names);
}

void DeltaSubscriptionImpl::updateResources(const std::set<std::string>& update_to_these_names) {
Expand Down
6 changes: 4 additions & 2 deletions source/common/config/delta_subscription_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ class DeltaSubscriptionImpl : public Subscription,
const Protobuf::MethodDescriptor& service_method,
absl::string_view type_url, Runtime::RandomGenerator& random,
Stats::Scope& scope, const RateLimitSettings& rate_limit_settings,
SubscriptionStats stats, std::chrono::milliseconds init_fetch_timeout);
SubscriptionCallbacks& callbacks, SubscriptionStats stats,
std::chrono::milliseconds init_fetch_timeout);

void pause();
void resume();

// Config::Subscription
void start(const std::set<std::string>& resources, SubscriptionCallbacks& callbacks) override;
void start(const std::set<std::string>& resource_names) override;
void updateResources(const std::set<std::string>& update_to_these_names) override;

// Config::GrpcStreamCallbacks
Expand Down Expand Up @@ -80,6 +81,7 @@ class DeltaSubscriptionImpl : public Subscription,
std::queue<UpdateAck> ack_queue_;

const LocalInfo::LocalInfo& local_info_;
SubscriptionCallbacks& callbacks_;
SubscriptionStats stats_;
Event::Dispatcher& dispatcher_;
std::chrono::milliseconds init_fetch_timeout_;
Expand Down
25 changes: 9 additions & 16 deletions source/common/config/filesystem_subscription_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,25 @@ namespace Envoy {
namespace Config {

FilesystemSubscriptionImpl::FilesystemSubscriptionImpl(
Event::Dispatcher& dispatcher, absl::string_view path, SubscriptionStats stats,
ProtobufMessage::ValidationVisitor& validation_visitor, Api::Api& api)
: path_(path), watcher_(dispatcher.createFilesystemWatcher()), stats_(stats), api_(api),
validation_visitor_(validation_visitor) {
watcher_->addWatch(path_, Filesystem::Watcher::Events::MovedTo, [this](uint32_t events) {
UNREFERENCED_PARAMETER(events);
Event::Dispatcher& dispatcher, absl::string_view path, SubscriptionCallbacks& callbacks,
SubscriptionStats stats, ProtobufMessage::ValidationVisitor& validation_visitor, Api::Api& api)
: path_(path), watcher_(dispatcher.createFilesystemWatcher()), callbacks_(callbacks),
stats_(stats), api_(api), validation_visitor_(validation_visitor) {
watcher_->addWatch(path_, Filesystem::Watcher::Events::MovedTo, [this](uint32_t) {
if (started_) {
refresh();
}
});
}

// Config::Subscription
void FilesystemSubscriptionImpl::start(const std::set<std::string>& resources,
Config::SubscriptionCallbacks& callbacks) {
// We report all discovered resources in the watched file.
UNREFERENCED_PARAMETER(resources);
callbacks_ = &callbacks;
void FilesystemSubscriptionImpl::start(const std::set<std::string>&) {
started_ = true;
// Attempt to read in case there is a file there already.
refresh();
}

void FilesystemSubscriptionImpl::updateResources(const std::set<std::string>& resources) {
// We report all discovered resources in the watched file.
UNREFERENCED_PARAMETER(resources);
void FilesystemSubscriptionImpl::updateResources(const std::set<std::string>&) {
// Bump stats for consistence behavior with other xDS.
stats_.update_attempt_.inc();
}
Expand All @@ -47,7 +40,7 @@ void FilesystemSubscriptionImpl::refresh() {
try {
MessageUtil::loadFromFile(path_, message, validation_visitor_, api_);
config_update_available = true;
callbacks_->onConfigUpdate(message.resources(), message.version_info());
callbacks_.onConfigUpdate(message.resources(), message.version_info());
stats_.version_.set(HashUtil::xxHash64(message.version_info()));
stats_.update_success_.inc();
ENVOY_LOG(debug, "Filesystem config update accepted for {}: {}", path_, message.DebugString());
Expand All @@ -60,7 +53,7 @@ void FilesystemSubscriptionImpl::refresh() {
ENVOY_LOG(warn, "Filesystem config update failure: {}", e.what());
stats_.update_failure_.inc();
}
callbacks_->onConfigUpdateFailed(&e);
callbacks_.onConfigUpdateFailed(&e);
}
}

Expand Down
12 changes: 6 additions & 6 deletions source/common/config/filesystem_subscription_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ class FilesystemSubscriptionImpl : public Config::Subscription,
Logger::Loggable<Logger::Id::config> {
public:
FilesystemSubscriptionImpl(Event::Dispatcher& dispatcher, absl::string_view path,
SubscriptionStats stats,
SubscriptionCallbacks& callbacks, SubscriptionStats stats,
ProtobufMessage::ValidationVisitor& validation_visitor, Api::Api& api);

// Config::Subscription
void start(const std::set<std::string>& resources,
Config::SubscriptionCallbacks& callbacks) override;

void updateResources(const std::set<std::string>& resources) override;
// We report all discovered resources in the watched file, so the resource names arguments are
// unused, and updateResources is a no-op (other than updating a stat).
void start(const std::set<std::string>&) override;
void updateResources(const std::set<std::string>&) override;

private:
void refresh();

bool started_{};
const std::string path_;
std::unique_ptr<Filesystem::Watcher> watcher_;
SubscriptionCallbacks* callbacks_{};
SubscriptionCallbacks& callbacks_;
SubscriptionStats stats_;
Api::Api& api_;
ProtobufMessage::ValidationVisitor& validation_visitor_;
Expand Down
20 changes: 0 additions & 20 deletions source/common/config/filter_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,26 +397,6 @@ void FilterJson::translateTcpProxy(
}
}

void FilterJson::translateTcpRateLimitFilter(
const Json::Object& json_config,
envoy::config::filter::network::rate_limit::v2::RateLimit& proto_config) {
json_config.validateSchema(Json::Schema::RATELIMIT_NETWORK_FILTER_SCHEMA);

JSON_UTIL_SET_STRING(json_config, proto_config, stat_prefix);
JSON_UTIL_SET_STRING(json_config, proto_config, domain);
JSON_UTIL_SET_DURATION(json_config, proto_config, timeout);

auto* descriptors = proto_config.mutable_descriptors();
for (const auto& json_descriptor : json_config.getObjectArray("descriptors", false)) {
auto* entries = descriptors->Add()->mutable_entries();
for (const auto& json_entry : json_descriptor->asObjectArray()) {
auto* entry = entries->Add();
JSON_UTIL_SET_STRING(*json_entry, *entry, key);
JSON_UTIL_SET_STRING(*json_entry, *entry, value);
}
}
}

void FilterJson::translateHttpRateLimitFilter(
const Json::Object& json_config,
envoy::config::filter::http::rate_limit::v2::RateLimit& proto_config) {
Expand Down
11 changes: 0 additions & 11 deletions source/common/config/filter_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "envoy/config/filter/network/client_ssl_auth/v2/client_ssl_auth.pb.h"
#include "envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.pb.h"
#include "envoy/config/filter/network/mongo_proxy/v2/mongo_proxy.pb.h"
#include "envoy/config/filter/network/rate_limit/v2/rate_limit.pb.h"
#include "envoy/config/filter/network/redis_proxy/v2/redis_proxy.pb.h"
#include "envoy/config/filter/network/tcp_proxy/v2/tcp_proxy.pb.h"
#include "envoy/json/json_object.h"
Expand Down Expand Up @@ -141,16 +140,6 @@ class FilterJson {
translateTcpProxy(const Json::Object& json_config,
envoy::config::filter::network::tcp_proxy::v2::TcpProxy& proto_config);

/**
* Translate a v1 JSON TCP Rate Limit filter object to v2
* envoy::config::filter::network::rate_limit::v2::RateLimit.
* @param json_config source v1 JSON Tcp Rate Limit Filter object.
* @param proto_config destination v2 envoy::config::filter::network::rate_limit::v2::RateLimit.
*/
static void translateTcpRateLimitFilter(
const Json::Object& json_config,
envoy::config::filter::network::rate_limit::v2::RateLimit& proto_config);

/**
* Translate a v1 JSON HTTP Rate Limit filter object to v2
* envoy::config::filter::http::rate_limit::v2::RateLimit.
Expand Down
21 changes: 10 additions & 11 deletions source/common/config/grpc_mux_subscription_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@
namespace Envoy {
namespace Config {

GrpcMuxSubscriptionImpl::GrpcMuxSubscriptionImpl(GrpcMux& grpc_mux, SubscriptionStats stats,
GrpcMuxSubscriptionImpl::GrpcMuxSubscriptionImpl(GrpcMux& grpc_mux,
SubscriptionCallbacks& callbacks,
SubscriptionStats stats,
absl::string_view type_url,
Event::Dispatcher& dispatcher,
std::chrono::milliseconds init_fetch_timeout)
: grpc_mux_(grpc_mux), stats_(stats), type_url_(type_url), dispatcher_(dispatcher),
init_fetch_timeout_(init_fetch_timeout) {}
: grpc_mux_(grpc_mux), callbacks_(callbacks), stats_(stats), type_url_(type_url),
dispatcher_(dispatcher), init_fetch_timeout_(init_fetch_timeout) {}

// Config::Subscription
void GrpcMuxSubscriptionImpl::start(const std::set<std::string>& resources,
SubscriptionCallbacks& callbacks) {
callbacks_ = &callbacks;

void GrpcMuxSubscriptionImpl::start(const std::set<std::string>& resources) {
if (init_fetch_timeout_.count() > 0) {
init_fetch_timeout_timer_ = dispatcher_.createTimer([this]() -> void {
ENVOY_LOG(warn, "gRPC config: initial fetch timed out for {}", type_url_);
callbacks_->onConfigUpdateFailed(nullptr);
callbacks_.onConfigUpdateFailed(nullptr);
});
init_fetch_timeout_timer_->enableTimer(init_fetch_timeout_);
}
Expand Down Expand Up @@ -54,7 +53,7 @@ void GrpcMuxSubscriptionImpl::onConfigUpdate(
// supply those versions to onConfigUpdate() along with the xDS response ("system")
// version_info. This way, both types of versions can be tracked and exposed for debugging by
// the configuration update targets.
callbacks_->onConfigUpdate(resources, version_info);
callbacks_.onConfigUpdate(resources, version_info);
stats_.update_success_.inc();
stats_.update_attempt_.inc();
stats_.version_.set(HashUtil::xxHash64(version_info));
Expand All @@ -73,11 +72,11 @@ void GrpcMuxSubscriptionImpl::onConfigUpdateFailed(const EnvoyException* e) {
ENVOY_LOG(warn, "gRPC config for {} rejected: {}", type_url_, e->what());
}
stats_.update_attempt_.inc();
callbacks_->onConfigUpdateFailed(e);
callbacks_.onConfigUpdateFailed(e);
}

std::string GrpcMuxSubscriptionImpl::resourceName(const ProtobufWkt::Any& resource) {
return callbacks_->resourceName(resource);
return callbacks_.resourceName(resource);
}

void GrpcMuxSubscriptionImpl::disableInitFetchTimeoutTimer() {
Expand Down
Loading

0 comments on commit b2222be

Please sign in to comment.