Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions src/core/client_channel/client_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ void ClientChannel::StartCall(UnstartedCallHandler unstarted_handler) {
// resolver.
auto destination =
DownCast<const FilterChainImpl*>(filter_chain->get())
->destination();
->destination();
destination->StartCall(std::move(unstarted_handler));
return absl::OkStatus();
});
Expand Down Expand Up @@ -1445,9 +1445,9 @@ ClientChannel::ApplyServiceConfigToCall(
GetContext<Arena>()->New<ClientChannelServiceConfigCallData>(
GetContext<Arena>());
// Use the ConfigSelector to determine the config for the call.
auto filter_chain = config_selector.GetCallConfig(
{&client_initial_metadata, GetContext<Arena>(),
service_config_call_data});
auto filter_chain = config_selector.GetCallConfig({&client_initial_metadata,
GetContext<Arena>(),
service_config_call_data});
if (!filter_chain.ok()) {
return MaybeRewriteIllegalStatusCode(filter_chain.status(),
"ConfigSelector");
Expand Down
7 changes: 3 additions & 4 deletions src/core/client_channel/client_channel_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1858,10 +1858,9 @@ grpc_error_handle ClientChannelFilter::CallData::ApplyServiceConfigToCallLocked(
auto* service_config_call_data =
arena()->New<ClientChannelServiceConfigCallData>(arena());
// Use the ConfigSelector to determine the config for the call.
auto filter_chain =
(*config_selector)
->GetCallConfig(
{send_initial_metadata(), arena(), service_config_call_data});
auto filter_chain = (*config_selector)
->GetCallConfig({send_initial_metadata(), arena(),
service_config_call_data});
if (!filter_chain.ok()) {
return absl_status_to_grpc_error(
MaybeRewriteIllegalStatusCode(filter_chain.status(), "ConfigSelector"));
Expand Down
2 changes: 1 addition & 1 deletion src/core/client_channel/config_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ConfigSelector : public RefCounted<ConfigSelector> {
const Blackboard* old_blackboard,
Blackboard* new_blackboard) = 0;

// FIXME: remove
// FIXME: remove
// The channel will call this when the resolver returns a new ConfigSelector
// to determine what set of dynamic filters will be configured.
virtual void AddFilters(InterceptionChainBuilder& /*builder*/,
Expand Down
32 changes: 15 additions & 17 deletions src/core/ext/filters/fault_injection/fault_injection_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ namespace grpc_core {

bool FaultInjectionFilter::Config::Equals(const FilterConfig& other) const {
const auto& o = DownCast<const Config&>(other);
return abort_code == o.abort_code &&
abort_message == o.abort_message &&
return abort_code == o.abort_code && abort_message == o.abort_message &&
abort_code_header == o.abort_code_header &&
abort_percentage_header == o.abort_percentage_header &&
delay == o.delay &&
delay_header == o.delay_header &&
delay == o.delay && delay_header == o.delay_header &&
delay_percentage_header == o.delay_percentage_header &&
delay_percentage_numerator == o.delay_percentage_numerator &&
delay_percentage_denominator == o.delay_percentage_denominator &&
Expand All @@ -75,22 +73,22 @@ std::string FaultInjectionFilter::Config::ToString() const {
absl::StrCat("abort_code_header=\"", abort_code_header, "\""));
}
if (!abort_percentage_header.empty()) {
parts.push_back(absl::StrCat(
"abort_percentage_header=\"", abort_percentage_header, "\""));
parts.push_back(absl::StrCat("abort_percentage_header=\"",
abort_percentage_header, "\""));
}
parts.push_back(absl::StrCat(
"abort_percentage_numerator=", abort_percentage_numerator));
parts.push_back(absl::StrCat(
"abort_percentage_denominator=", abort_percentage_denominator));
parts.push_back(absl::StrCat("abort_percentage_numerator=",
abort_percentage_numerator));
parts.push_back(absl::StrCat("abort_percentage_denominator=",
abort_percentage_denominator));
}
if (delay != Duration::Zero()) {
parts.push_back(absl::StrCat("delay=", delay.ToString()));
if (!delay_header.empty()) {
parts.push_back(absl::StrCat("delay_header=\"", delay_header, "\""));
}
if (!delay_percentage_header.empty()) {
parts.push_back(absl::StrCat(
"delay_percentage_header=\"", delay_percentage_header, "\""));
parts.push_back(absl::StrCat("delay_percentage_header=\"",
delay_percentage_header, "\""));
}
}
parts.push_back(absl::StrCat("max_faults=", max_faults));
Expand Down Expand Up @@ -176,9 +174,9 @@ absl::StatusOr<std::unique_ptr<FaultInjectionFilter>>
FaultInjectionFilter::Create(const ChannelArgs&,
ChannelFilter::Args filter_args) {
if (filter_args.config()->type() != Config::Type()) {
return absl::InternalError(absl::StrCat(
"wrong config type passed to fault injection filter: ",
filter_args.config()->type().name()));
return absl::InternalError(
absl::StrCat("wrong config type passed to fault injection filter: ",
filter_args.config()->type().name()));
}
return std::make_unique<FaultInjectionFilter>(filter_args);
}
Expand Down Expand Up @@ -311,8 +309,8 @@ FaultInjectionFilter::MakeInjectionDecision(
!config_->delay_percentage_header.empty()) {
std::string buffer;
if (!config_->abort_code_header.empty() && abort_code == GRPC_STATUS_OK) {
auto value = initial_metadata.GetStringValue(config_->abort_code_header,
&buffer);
auto value =
initial_metadata.GetStringValue(config_->abort_code_header, &buffer);
if (value.has_value()) {
grpc_status_code_from_int(
AsInt<int>(*value).value_or(GRPC_STATUS_UNKNOWN), &abort_code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class FaultInjectionFilter
InjectionDecision MakeInjectionDecision(
const ClientMetadata& initial_metadata);

// FIXME: remove
// FIXME: remove
// The relative index of instances of the same filter.
size_t index_;
const size_t service_config_parser_index_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ bool GcpAuthenticationFilter::Config::Equals(const FilterConfig& other) const {
}

std::string GcpAuthenticationFilter::Config::ToString() const {
return absl::StrCat("{instance_name=\"", instance_name, "\", cache_size=",
cache_size, "}");
return absl::StrCat("{instance_name=\"", instance_name,
"\", cache_size=", cache_size, "}");
}

//
Expand Down Expand Up @@ -184,9 +184,9 @@ GcpAuthenticationFilter::Create(const ChannelArgs& args,
}
#endif
if (filter_args.config()->type() != Config::Type()) {
return absl::InternalError(absl::StrCat(
"wrong config type passed to GCP authn filter: ",
filter_args.config()->type().name()));
return absl::InternalError(
absl::StrCat("wrong config type passed to GCP authn filter: ",
filter_args.config()->type().name()));
}
auto config = filter_args.config().TakeAsSubclass<const Config>();
// Get cache from blackboard. This must have been populated
Expand All @@ -198,9 +198,8 @@ GcpAuthenticationFilter::Create(const ChannelArgs& args,
"gcp_auth: cache object not found in filter state");
}
// Instantiate filter.
return std::unique_ptr<GcpAuthenticationFilter>(
new GcpAuthenticationFilter(std::move(config), std::move(xds_config),
std::move(cache)));
return std::unique_ptr<GcpAuthenticationFilter>(new GcpAuthenticationFilter(
std::move(config), std::move(xds_config), std::move(cache)));
}

GcpAuthenticationFilter::GcpAuthenticationFilter(
Expand Down
21 changes: 9 additions & 12 deletions src/core/ext/filters/stateful_session/stateful_session_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ UniqueTypeName XdsOverrideHostAttribute::TypeName() {

std::string StatefulSessionFilter::CookieConfig::ToString() const {
std::vector<std::string> parts = {
absl::StrCat("name=\"", name, "\""),
absl::StrCat("name=\"", name, "\""),
};
if (ttl != Duration::Zero()) {
parts.push_back(absl::StrCat("ttl=", ttl.ToString()));
Expand Down Expand Up @@ -117,9 +117,8 @@ absl::string_view AllocateStringOnArena(

// Adds the set-cookie header to the server initial metadata if needed.
void MaybeUpdateServerInitialMetadata(
const StatefulSessionFilter::CookieConfig& config,
bool cluster_changed, absl::string_view actual_cluster,
absl::string_view cookie_address_list,
const StatefulSessionFilter::CookieConfig& config, bool cluster_changed,
absl::string_view actual_cluster, absl::string_view cookie_address_list,
XdsOverrideHostAttribute* override_host_attribute,
ServerMetadata& server_initial_metadata) {
// If cookie doesn't need to change, do nothing.
Expand Down Expand Up @@ -289,10 +288,9 @@ void StatefulSessionFilter::Call::OnServerInitialMetadata(
GRPC_LATENT_SEE_SCOPE("StatefulSessionFilter::Call::OnServerInitialMetadata");
if (!perform_filtering_) return;
// Add cookie to server initial metadata if needed.
MaybeUpdateServerInitialMetadata(filter->config_->cookie_config,
cluster_changed_, cluster_name_,
cookie_address_list_,
override_host_attribute_, md);
MaybeUpdateServerInitialMetadata(
filter->config_->cookie_config, cluster_changed_, cluster_name_,
cookie_address_list_, override_host_attribute_, md);
}

void StatefulSessionFilter::Call::OnServerTrailingMetadata(
Expand All @@ -304,10 +302,9 @@ void StatefulSessionFilter::Call::OnServerTrailingMetadata(
// cookie to the trailing metadata instead of the
// initial metadata.
if (md.get(GrpcTrailersOnly()).value_or(false)) {
MaybeUpdateServerInitialMetadata(filter->config_->cookie_config,
cluster_changed_, cluster_name_,
cookie_address_list_,
override_host_attribute_, md);
MaybeUpdateServerInitialMetadata(
filter->config_->cookie_config, cluster_changed_, cluster_name_,
cookie_address_list_, override_host_attribute_, md);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class StatefulSessionFilter
private:
const RefCountedPtr<const Config> config_;

// FIXME: remove
// FIXME: remove
// The relative index of instances of the same filter.
const size_t index_;
// Index of the service config parser.
Expand Down
4 changes: 1 addition & 3 deletions src/core/filter/filter_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class FilterConfig : public RefCounted<FilterConfig> {
return Equals(other);
}

bool operator!=(const FilterConfig& other) const {
return !(*this == other);
}
bool operator!=(const FilterConfig& other) const { return !(*this == other); }

virtual bool Equals(const FilterConfig& other) const = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/core/filter/filter_chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FilterChainBuilderV1 {
// favor of just directly using UnstartedCallDestination.
class FilterChain : public RefCounted<FilterChain> {
public:
virtual ~FilterChain() = default;
~FilterChain() override = default;
};

// Abstract filter chain builder interface.
Expand Down
63 changes: 30 additions & 33 deletions src/core/resolver/xds/xds_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ class XdsResolver final : public Resolver {
RouteEntry* GetRouteForRequest(absl::string_view path,
grpc_metadata_batch* initial_metadata);

void BuildFilterChains(
const XdsConfig& xds_config,
const std::vector<const XdsHttpFilterImpl*>& filters,
FilterChainBuilder& builder, const Blackboard* old_blackboard,
Blackboard* new_blackboard);
void BuildFilterChains(const XdsConfig& xds_config,
const std::vector<const XdsHttpFilterImpl*>& filters,
FilterChainBuilder& builder,
const Blackboard* old_blackboard,
Blackboard* new_blackboard);

private:
class RouteListIterator;
Expand Down Expand Up @@ -436,7 +436,7 @@ RefCountedPtr<const FilterConfig> GetOverrideConfig(
}

void XdsResolver::RouteConfigData::BuildFilterChains(
const XdsConfig& xds_config,
const XdsConfig& xds_config,
const std::vector<const XdsHttpFilterImpl*>& filters,
FilterChainBuilder& builder, const Blackboard* old_blackboard,
Blackboard* new_blackboard) {
Expand All @@ -454,15 +454,15 @@ void XdsResolver::RouteConfigData::BuildFilterChains(
auto* filter = filters[i];
const auto& filter_config = hcm.http_filters[i];
if (filter_config.filter_config == nullptr) continue;
auto vhost_override_config = GetOverrideConfig(
xds_config.virtual_host->typed_per_filter_config,
filter_config.name);
auto config = filter->MergeConfigs(
filter_config.filter_config, std::move(vhost_override_config),
nullptr, nullptr);
auto vhost_override_config =
GetOverrideConfig(xds_config.virtual_host->typed_per_filter_config,
filter_config.name);
auto config = filter->MergeConfigs(filter_config.filter_config,
std::move(vhost_override_config),
nullptr, nullptr);
GRPC_TRACE_LOG(xds_resolver, INFO)
<< " Adding filter=" << filter_config.name << " config="
<< config->ToString();
<< " Adding filter=" << filter_config.name
<< " config=" << config->ToString();
filter->UpdateBlackboard({}, config.get(), old_blackboard,
new_blackboard);
filter->AddFilter(builder, std::move(config));
Expand All @@ -485,9 +485,8 @@ void XdsResolver::RouteConfigData::BuildFilterChains(
nullptr;
auto get_route_filter_chain = [&]() {
if (route_filter_chain.ok() && *route_filter_chain == nullptr) {
GRPC_TRACE_LOG(xds_resolver, INFO)
<< "Building filter chain for route:"
<< route_entry.route.ToString();
GRPC_TRACE_LOG(xds_resolver, INFO) << "Building filter chain for route:"
<< route_entry.route.ToString();
if (route_entry.route.typed_per_filter_config.empty()) {
// No per-route overrides, so use the default filter chain.
route_filter_chain = get_default_filter_chain();
Expand All @@ -505,26 +504,24 @@ void XdsResolver::RouteConfigData::BuildFilterChains(
filter_config.filter_config, std::move(vhost_override_config),
std::move(route_override_config), nullptr);
GRPC_TRACE_LOG(xds_resolver, INFO)
<< " Adding filter=" << filter_config.name << " config="
<< config->ToString();
<< " Adding filter=" << filter_config.name
<< " config=" << config->ToString();
filter->UpdateBlackboard({}, config.get(), old_blackboard,
new_blackboard);
filter->AddFilter(builder, std::move(config));
}
route_filter_chain = builder.Build();
GRPC_TRACE_LOG(xds_resolver, INFO)
<< "Filter chain creation status: "
<< route_filter_chain.status();
GRPC_TRACE_LOG(xds_resolver, INFO) << "Filter chain creation status: "
<< route_filter_chain.status();
}
}
return route_filter_chain;
};
// If the route uses WeightedClusters, construct a filter chain for
// each ClusterWeight entry.
if (const auto* weighted_clusters =
std::get_if<std::vector<
XdsRouteConfigResource::Route::RouteAction::ClusterWeight>>(
&route_action->action);
if (const auto* weighted_clusters = std::get_if<std::vector<
XdsRouteConfigResource::Route::RouteAction::ClusterWeight>>(
&route_action->action);
weighted_clusters != nullptr) {
GRPC_CHECK_EQ(weighted_clusters->size(),
route_entry.weighted_cluster_state.size());
Expand All @@ -549,16 +546,16 @@ void XdsResolver::RouteConfigData::BuildFilterChains(
filter_config.name);
auto route_override_config = GetOverrideConfig(
route_entry.route.typed_per_filter_config, filter_config.name);
auto cluster_weight_override_config = GetOverrideConfig(
cluster_weight_entry.typed_per_filter_config,
filter_config.name);
auto cluster_weight_override_config =
GetOverrideConfig(cluster_weight_entry.typed_per_filter_config,
filter_config.name);
auto config = filter->MergeConfigs(
filter_config.filter_config, std::move(vhost_override_config),
std::move(route_override_config),
std::move(cluster_weight_override_config));
GRPC_TRACE_LOG(xds_resolver, INFO)
<< " Adding filter=" << filter_config.name << " config="
<< config->ToString();
<< " Adding filter=" << filter_config.name
<< " config=" << config->ToString();
filter->UpdateBlackboard({}, config.get(), old_blackboard,
new_blackboard);
filter->AddFilter(builder, std::move(config));
Expand Down Expand Up @@ -960,8 +957,8 @@ XdsResolver::XdsConfigSelector::GetFilters(const Blackboard* old_blackboard,
void XdsResolver::XdsConfigSelector::BuildFilterChains(
FilterChainBuilder& builder, const Blackboard* old_blackboard,
Blackboard* new_blackboard) {
route_config_data_->BuildFilterChains(
*xds_config_, filters_, builder, old_blackboard, new_blackboard);
route_config_data_->BuildFilterChains(*xds_config_, filters_, builder,
old_blackboard, new_blackboard);
}

//
Expand Down
3 changes: 1 addition & 2 deletions src/core/server/xds_server_config_fetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,7 @@ void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
nullptr); // Enforced in config validation.
filter_impl->UpdateBlackboard(http_filter.config,
nullptr, // FIXME
old_blackboard,
new_blackboard);
old_blackboard, new_blackboard);
}
});
}
Expand Down
Loading