Skip to content
Merged
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
11 changes: 4 additions & 7 deletions source/common/router/scoped_rds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper::initRdsConfigPro

rds_update_callback_handle_ = route_provider_->subscription().addUpdateCallback([this]() {
// Subscribe to RDS update.
parent_.onRdsConfigUpdate(scope_name_, route_provider_->subscription());
parent_.onRdsConfigUpdate(scope_name_, route_provider_->config());
});
parent_.stats_.active_scopes_.inc();
}
Expand Down Expand Up @@ -231,7 +231,7 @@ void ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper::maybeInitRdsConf
return;
}
// If RouteConfiguration has been initialized, apply update to all the threads.
parent_.onRdsConfigUpdate(scope_name_, route_provider_->subscription());
parent_.onRdsConfigUpdate(scope_name_, route_provider_->config());
}

bool ScopedRdsConfigSubscription::addOrUpdateScopes(
Expand Down Expand Up @@ -393,16 +393,13 @@ void ScopedRdsConfigSubscription::onConfigUpdate(
}

void ScopedRdsConfigSubscription::onRdsConfigUpdate(const std::string& scope_name,
RdsRouteConfigSubscription& rds_subscription) {
ConfigConstSharedPtr new_rds_config) {
auto iter = scoped_route_map_.find(scope_name);
ASSERT(iter != scoped_route_map_.end(),
fmt::format("trying to update route config for non-existing scope {}", scope_name));
auto new_scoped_route_info = std::make_shared<ScopedRouteInfo>(
envoy::config::route::v3::ScopedRouteConfiguration(iter->second->configProto()),
std::make_shared<ConfigImpl>(
rds_subscription.routeConfigUpdate()->protobufConfiguration(), optional_http_filters_,
factory_context_, factory_context_.messageValidationContext().dynamicValidationVisitor(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you confirm the Config doesn't hold a factory_context_ from another networkfilterchain/listener?
Reuse a protobuf nessage is pretty safe but Config is risk when the config is shared among different filter chain. There were a lot of issues

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they all use the factory_context_ of ScopedRdsConfigSubscription.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this rds-config-provider was fully owned by the SRDS subscription, the factory_context_ is from ScopedRdsConfigSubscription, see how RdsRouteConfigProviderHelper::initRdsConfigProvider works, which is inherited from the listener that started the srds subscription.
the life-cycle of these objects are:
{SRDS-subscription { RDS-subscription, RDS-CofigProvider } }
so it should be fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for hte explanation!

false));
std::move(new_rds_config));
applyConfigUpdate([new_scoped_route_info](ConfigProvider::ConfigConstSharedPtr config)
-> ConfigProvider::ConfigConstSharedPtr {
auto* thread_local_scoped_config =
Expand Down
3 changes: 1 addition & 2 deletions source/common/router/scoped_rds.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ class ScopedRdsConfigSubscription
DeltaConfigSubscriptionInstance::onConfigUpdateFailed();
}
// Propagate RDS updates to ScopeConfigImpl in workers.
void onRdsConfigUpdate(const std::string& scope_name,
RdsRouteConfigSubscription& rds_subscription);
void onRdsConfigUpdate(const std::string& scope_name, ConfigConstSharedPtr new_rds_config);

// ScopedRouteInfo by scope name.
ScopedRouteMap scoped_route_map_;
Expand Down