rds: make RouteConfigProvider unique_ptr#3967
rds: make RouteConfigProvider unique_ptr#3967mattklein123 merged 7 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Lizan Zhou <zlizan@google.com>
mattklein123
left a comment
There was a problem hiding this comment.
Thanks, awesome cleanup.
| * dynamic (RDS) RouteConfigProviders currently loaded. | ||
| */ | ||
| virtual std::vector<RouteConfigProviderSharedPtr> getRdsRouteConfigProviders() PURE; | ||
| virtual std::vector<RouteConfigProvider*> getRdsRouteConfigProviders() PURE; |
There was a problem hiding this comment.
nit: Can we potentially return std::reference_wrappers here and below? Since these can never be null it would be a bit cleaner.
There was a problem hiding this comment.
It is better to return list of RdsSubscription which is what the manager is holding. This function is only used for dumping RDS config. RdsSubscription is good enough
There was a problem hiding this comment.
RdsSubscription is not implementing the RouteConfigProvider interface and there is no corresponding interface.
Do we really need these two methods (get{Rds,Static}RouteConfigProviders) in RouteConfigProviderManager interface? It is only used in rds_impl_test and RouteConfigProviderManagerImpl itself to dump config. cc @jsedgwick @htuch
There was a problem hiding this comment.
I don't recall the entire history here. It's possible the methods are not needed anymore with iterative changes. Feel free to remove them if it's possible.
There was a problem hiding this comment.
+1, remove any methods from the interface that don't have external callers.
- add more tests - make dump config public Signed-off-by: Lizan Zhou <zlizan@google.com>
source/common/router/rds_impl.cc
Outdated
| dynamic_config->set_version_info(subscription->config_info_.value().last_config_version_); | ||
| dynamic_config->mutable_route_config()->MergeFrom(subscription->route_config_proto_); | ||
| } | ||
| TimestampUtil::systemClockToTimestamp(subscription->last_updated_, |
There was a problem hiding this comment.
if subscription did not receive its first config (config_info_ is empty case), I think we don't need to create a config_dump entry.
There was a problem hiding this comment.
I did this change intentionally as you want to know the RDS config is delivered but not received route from RDS. And it is easier to track how many RDS subscription Envoy has from config dump, thoughs?
There was a problem hiding this comment.
OK, it will be useful to know there is such subscriptions that did not even receive the first responses.
There was a problem hiding this comment.
Are you sure last_updated_ actually points to something meaningful here? Is it going to be 0 or the equivalent epoch? I guess I'm asking what will this actually output. :)
My preference would actually be to do this change in a follow up as a discrete change, and we should be consistent across all the xDS? Thoughts?
There was a problem hiding this comment.
+1, prefer behavioral changes like this to be split out.
There was a problem hiding this comment.
It will be initialized when the subscription started:
envoy/source/common/router/rds_impl.cc
Line 60 in 028387a
Sure, I will make a separate PR.
There was a problem hiding this comment.
I reverted this part for this PR.
| route_config_provider_manager_->getRdsRouteConfigProviders(); | ||
| EXPECT_EQ(2UL, configured_providers.size()); | ||
| EXPECT_EQ(2UL, | ||
| route_config_provider_manager_->dumpRouteConfigs()->dynamic_route_configs().size()); |
There was a problem hiding this comment.
We only have one subscription, how can we have 2 dynamic route configs? Should it be 1?
There was a problem hiding this comment.
we have two RDS config, rds_ and rds2, they are keyed by full Rds message, not only the name, they have different cluster.
test/mocks/router/mocks.h
Outdated
| MOCK_METHOD2(createStaticRouteConfigProvider, | ||
| RouteConfigProviderPtr(const envoy::api::v2::RouteConfiguration& route_config, | ||
| Server::Configuration::FactoryContext& factory_context)); | ||
| MOCK_METHOD0(getRdsRouteConfigProviders, std::vector<RouteConfigProvider*>()); |
There was a problem hiding this comment.
why these two functions are still in the mock? I thought they are removed.
…rs() Signed-off-by: Lizan Zhou <zlizan@google.com>
mattklein123
left a comment
There was a problem hiding this comment.
Awesome cleanup, thanks. One question.
source/common/router/rds_impl.cc
Outdated
| dynamic_config->set_version_info(subscription->config_info_.value().last_config_version_); | ||
| dynamic_config->mutable_route_config()->MergeFrom(subscription->route_config_proto_); | ||
| } | ||
| TimestampUtil::systemClockToTimestamp(subscription->last_updated_, |
There was a problem hiding this comment.
Are you sure last_updated_ actually points to something meaningful here? Is it going to be 0 or the equivalent epoch? I guess I'm asking what will this actually output. :)
My preference would actually be to do this change in a follow up as a discrete change, and we should be consistent across all the xDS? Thoughts?
source/common/router/rds_impl.cc
Outdated
| dynamic_config->set_version_info(subscription->config_info_.value().last_config_version_); | ||
| dynamic_config->mutable_route_config()->MergeFrom(subscription->route_config_proto_); | ||
| } | ||
| TimestampUtil::systemClockToTimestamp(subscription->last_updated_, |
There was a problem hiding this comment.
+1, prefer behavioral changes like this to be split out.
Signed-off-by: Lizan Zhou <zlizan@google.com>
|
@lizan LGTM but needs format fix. |
Signed-off-by: Lizan Zhou <zlizan@google.com>
Signed-off-by: Lizan Zhou zlizan@google.com
Description:
RouteConfigProvider is no longer shared ownership, make it unique_ptr.
Follow up of #3960.
Risk Level: Low
Testing: unit test, integration tests
Docs Changes: N/A
Release Notes: N/A