Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
97fe893
Adding ECDS config dump support.
yanjunxiang-google Nov 8, 2022
0c6e887
fixing format error
yanjunxiang-google Nov 8, 2022
dc3beaa
fixing proto format
yanjunxiang-google Nov 8, 2022
e7cdb8b
addressign comments
yanjunxiang-google Nov 9, 2022
bb18bb5
adding more integration tests to cover both HTTP and TCP listener fi…
yanjunxiang-google Nov 10, 2022
fc3ad87
using subscription hash map for config dump
yanjunxiang-google Nov 10, 2022
010083d
fixing format errors
yanjunxiang-google Nov 10, 2022
6709e1a
adding a test case to cover two filter case with same type to cover …
yanjunxiang-google Nov 10, 2022
9029f70
merge upstream main
yanjunxiang-google Nov 10, 2022
1591ff8
addressing comments
yanjunxiang-google Nov 14, 2022
55d4f91
addressing comments, verify the subscription config exits
yanjunxiang-google Nov 14, 2022
0f7d24c
adding tests to verify subscription being removed case
yanjunxiang-google Nov 15, 2022
9cf4999
adding ECDS config dump documentation, also adding an integration te…
yanjunxiang-google Nov 15, 2022
f397a10
addressing comments
yanjunxiang-google Nov 16, 2022
338051a
Merge branch 'main' of https://github.com/envoyproxy/envoy into ecds_…
yanjunxiang-google Nov 16, 2022
78941be
pull upstream main and resolve build errors
yanjunxiang-google Nov 16, 2022
39d59fa
adding a comment for a new added funcion
yanjunxiang-google Nov 16, 2022
d09821c
disable config_dump test if admin interface is disabled
yanjunxiang-google Nov 16, 2022
12fec5a
addressing comments to generalize ECDS message sending
yanjunxiang-google Nov 22, 2022
6f74fc4
adjusting test coverage nuber for source/common/filter due to upstre…
yanjunxiang-google Nov 22, 2022
ca81027
Merge branch 'main' of https://github.com/envoyproxy/envoy into ecds_…
yanjunxiang-google Nov 23, 2022
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: 40 additions & 0 deletions api/envoy/admin/v3/config_dump_shared.proto
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,43 @@ message EndpointsConfigDump {
// The dynamically loaded endpoint configs.
repeated DynamicEndpointConfig dynamic_endpoint_configs = 3;
}

// Envoy's ECDS service fills this message with all currently extension
// configuration. Extension configuration information can be used to recreate
// an Envoy ECDS listener and HTTP filters as static filters or by returning
// them in ECDS response.
message EcdsConfigDump {
option (udpa.annotations.versioning).previous_message_type = "envoy.admin.v2alpha.EcdsConfigDump";

// [#next-free-field: 6]
message EcdsFilterConfig {
option (udpa.annotations.versioning).previous_message_type =
"envoy.admin.v2alpha.EcdsConfigDump.EcdsFilterConfig";

// This is the per-resource version information. This version is currently
// taken from the :ref:`version_info
// <envoy_v3_api_field_service.discovery.v3.DiscoveryResponse.version_info>`
// field at the time that the ECDS filter was loaded.
string version_info = 1;

// The ECDS filter config.
google.protobuf.Any ecds_filter = 2;

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

// Set if the last update failed, cleared after the next successful update.
// The ``error_state`` field contains the rejected version of this
// particular resource along with the reason and timestamp. For successfully
// updated or acknowledged resource, this field should be empty.
// [#not-implemented-hide:]
UpdateFailureState error_state = 4;

// The client status of this resource.
// [#not-implemented-hide:]
ClientResourceStatus client_status = 5;
}

// The ECDS filter configs.
repeated EcdsFilterConfig ecds_filters = 1;
}
1 change: 1 addition & 0 deletions source/common/filter/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ envoy_cc_library(
"//source/common/init:target_lib",
"//source/common/init:watcher_lib",
"//source/common/protobuf:utility_lib",
"@envoy_api//envoy/admin/v3:pkg_cc_proto",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
],
)
5 changes: 5 additions & 0 deletions source/common/filter/config_discovery_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void FilterConfigSubscription::onConfigUpdate(
last_type_url_ = type_url;
last_version_info_ = version_info;
last_factory_name_ = factory_name;
last_updated_ = factory_context_.timeSource().systemTime();
}

void FilterConfigSubscription::onConfigUpdate(
Expand All @@ -151,6 +152,7 @@ void FilterConfigSubscription::onConfigUpdate(
last_type_url_ = "";
last_version_info_ = "";
last_factory_name_ = "";
last_updated_ = factory_context_.timeSource().systemTime();
} else if (!added_resources.empty()) {
onConfigUpdate(added_resources, added_resources[0].get().version());
}
Expand All @@ -177,6 +179,9 @@ void FilterConfigSubscription::incrementConflictCounter() { stats_.config_confli
std::shared_ptr<FilterConfigSubscription> FilterConfigProviderManagerImplBase::getSubscription(
const envoy::config::core::v3::ConfigSource& config_source, const std::string& name,
Server::Configuration::ServerFactoryContext& server_context, const std::string& stat_prefix) {
// There are ECDS filters configured. Setup ECDS config dump call backs.
setupEcdsConfigDumpCallbacks(server_context.admin());

// FilterConfigSubscriptions are unique based on their config source and filter config name
// combination.
// TODO(https://github.com/envoyproxy/envoy/issues/11967) Hash collision can cause subscription
Expand Down
46 changes: 46 additions & 0 deletions source/common/filter/config_discovery_impl.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#pragma once

#include "envoy/admin/v3/config_dump.pb.h"
#include "envoy/config/core/v3/extension.pb.h"
#include "envoy/config/core/v3/extension.pb.validate.h"
#include "envoy/config/extension_config_provider.h"
#include "envoy/config/subscription.h"
#include "envoy/filter/config_provider_manager.h"
#include "envoy/http/filter.h"
#include "envoy/protobuf/message_validator.h"
#include "envoy/server/admin.h"
#include "envoy/server/factory_context.h"
#include "envoy/singleton/instance.h"
#include "envoy/stats/scope.h"
Expand Down Expand Up @@ -307,6 +309,8 @@ class FilterConfigSubscription
const std::string& lastTypeUrl() { return last_type_url_; }
const std::string& lastVersionInfo() { return last_version_info_; }
const std::string& lastFactoryName() { return last_factory_name_; }
const SystemTime& lastUpdated() { return last_updated_; }

void incrementConflictCounter();

private:
Expand All @@ -327,6 +331,7 @@ class FilterConfigSubscription
std::string last_type_url_;
std::string last_version_info_;
std::string last_factory_name_;
SystemTime last_updated_;
Server::Configuration::ServerFactoryContext& factory_context_;

Init::SharedTargetImpl init_target_;
Expand Down Expand Up @@ -387,9 +392,42 @@ class FilterConfigProviderManagerImplBase : Logger::Loggable<Logger::Id::filter>
absl::string_view type_url) const;
void validateProtoConfigTypeUrl(const std::string& type_url,
const absl::flat_hash_set<std::string>& require_type_urls) const;
virtual const std::string getConfigDumpType() const PURE;
Comment thread
yanjunxiang-google marked this conversation as resolved.

private:
void setupEcdsConfigDumpCallbacks(Server::Admin& admin) {
if (config_tracker_entry_ == nullptr) {
config_tracker_entry_ = admin.getConfigTracker().add(
getConfigDumpType(), [this](const Matchers::StringMatcher& name_matcher) {
Comment thread
yanjunxiang-google marked this conversation as resolved.
return dumpEcdsFilterConfigs(name_matcher);
});
}
}

ProtobufTypes::MessagePtr dumpEcdsFilterConfigs(const Matchers::StringMatcher& name_matcher) {
auto config_dump = std::make_unique<envoy::admin::v3::EcdsConfigDump>();
for (const auto& subscription : subscriptions_) {
const auto& ecds_filter = subscription.second.lock();
Comment thread
yanjunxiang-google marked this conversation as resolved.
if (!name_matcher.match(ecds_filter->name())) {
continue;
}
// Put the filter info into a typed extension proto.
envoy::config::core::v3::TypedExtensionConfig filter_config;
Comment thread
yanjunxiang-google marked this conversation as resolved.
filter_config.set_name(ecds_filter->name());
filter_config.mutable_typed_config()->PackFrom(*ecds_filter->lastConfig());
Comment thread
yanjunxiang-google marked this conversation as resolved.
Outdated
// Set up the config dump proto.
auto& filter_config_dump = *config_dump->mutable_ecds_filters()->Add();
filter_config_dump.mutable_ecds_filter()->PackFrom(filter_config);
filter_config_dump.set_version_info(ecds_filter->lastVersionInfo());
TimestampUtil::systemClockToTimestamp(ecds_filter->lastUpdated(),
*(filter_config_dump.mutable_last_updated()));
}
return config_dump;
}


absl::flat_hash_map<std::string, std::weak_ptr<FilterConfigSubscription>> subscriptions_;
Server::ConfigTracker::EntryOwnerPtr config_tracker_entry_;
friend class FilterConfigSubscription;
};

Expand Down Expand Up @@ -528,6 +566,7 @@ class HttpFilterConfigProviderManagerImpl
Config::Utility::validateTerminalFilters(filter_config_name, filter_type, filter_chain_type,
is_terminal_filter, last_filter_in_filter_chain);
}
const std::string getConfigDumpType() const override { return "ecds_filter_http"; }
};

// HTTP filter
Expand All @@ -554,6 +593,7 @@ class UpstreamHttpFilterConfigProviderManagerImpl
Config::Utility::validateTerminalFilters(filter_config_name, filter_type, filter_chain_type,
is_terminal_filter, last_filter_in_filter_chain);
}
const std::string getConfigDumpType() const override { return "ecds_filter_upstream_http"; }
};

// TCP listener filter
Expand All @@ -564,6 +604,9 @@ class TcpListenerFilterConfigProviderManagerImpl
TcpListenerDynamicFilterConfigProviderImpl> {
public:
absl::string_view statPrefix() const override { return "tcp_listener_filter."; }

protected:
const std::string getConfigDumpType() const override { return "ecds_filter_tcp_listener"; }
Comment thread
kyessenov marked this conversation as resolved.
};

// UDP listener filter
Expand All @@ -574,6 +617,9 @@ class UdpListenerFilterConfigProviderManagerImpl
UdpListenerDynamicFilterConfigProviderImpl> {
public:
absl::string_view statPrefix() const override { return "udp_listener_filter."; }

protected:
const std::string getConfigDumpType() const override { return "ecds_filter_udp_listener"; }
};

} // namespace Filter
Expand Down
1 change: 1 addition & 0 deletions test/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,7 @@ envoy_cc_test(
"//test/integration/filters:set_is_terminal_filter_lib",
"//test/integration/filters:set_response_code_filter_config_proto_cc_proto",
"//test/integration/filters:set_response_code_filter_lib",
"//test/integration/filters:test_listener_filter_lib",
"//test/test_common:utility_lib",
"@envoy_api//envoy/extensions/common/matching/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/network/http_connection_manager/v3:pkg_cc_proto",
Expand Down
Loading