-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[xds] refactor config provider framework #7704
Changes from 1 commit
6a3f13b
cc806d7
bb55a44
8d7b4da
8bcddce
b1d0d5c
1007ee0
184ff2f
fe6b643
fc98e56
951bd28
75718d9
d84839d
27ff0a3
467a6a1
7dea1a0
2b5f572
86c455e
60dd433
c31de28
dad2d59
6b6a0ad
fb28731
1bd43be
f074e9d
7cbb6ae
fb7867b
47a417d
e328d46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,10 +216,10 @@ class ConfigSubscriptionCommonBase | |
* returns a updated/new version Config. | ||
* @param complete_cb the callback to run when the update propagation is done. | ||
*/ | ||
using ConfigUpdateCb = | ||
std::function<ConfigProvider::ConfigConstSharedPtr(ConfigProvider::ConfigConstSharedPtr)>; | ||
void applyConfigUpdate( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the simplification introduced by generalizing this function. It avoids delta vs non-delta code bloat which was a pending TODO. With that said, after thinking about this quite a bit, I think the "ConfigImpl" and the thread local storage on which it is stored are a better fit to be owned by the The proposal above would reintroduce the notion of bound config providers to a subscription, but I propose a new simplification here: instead of having multiple config providers bound to a subscription, have a single bound provider which owns the Effectively, this would translate into moving The modified approach would achieve several goals:
WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we had an offline discussion, the way proposed in above comment has a problem around the ownership of subscription&Providers, it can't guarantee a subscription gets teared down when there are no users(providers). We agreed that having a subscription maintains/owns the Config instance(s) make more sense for: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
To provide some more context, the design goal is to minimize duplication of config across consumers. The tradeoff that was made with the initial implementation of this framework was to provide more flexibility in how "config implementations" are stored (by having the ConfigProvider own the |
||
const std::function< | ||
ConfigProvider::ConfigConstSharedPtr(ConfigProvider::ConfigConstSharedPtr)>& update_fn, | ||
const Event::PostCb& complete_cb = []() {}) { | ||
const ConfigUpdateFn& update_fn, const Event::PostCb& complete_cb = []() {}) { | ||
// It is safe to call shared_from_this here as this is in main thread, and destruction of a | ||
// ConfigSubscriptionCommonBase owner (i.e., a provider) happens in main thread as well. | ||
auto shared_this = shared_from_this(); | ||
|
@@ -228,8 +228,8 @@ class ConfigSubscriptionCommonBase | |
tls_->getTyped<ThreadLocalConfig>().config_ = update_fn(this->getConfig()); | ||
}, | ||
/*During the update propagation, a subscription may get teared down in main thread due to | ||
all owners/providers destructed in a xDS update (e.g. LDS demolishes RouteConfigProvider and | ||
its subscription). Hold a reference to the shared subscription instance to make sure the | ||
all owners/providers destructed in a xDS update (e.g. LDS demolishes a RouteConfigProvider | ||
and its subscription). Hold a reference to the shared subscription instance to make sure the | ||
update can be safely pushed to workers in such an event.*/ | ||
[shared_this, complete_cb]() { complete_cb(); }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the capture be in the first lambda above, where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. If the race ever happens, we need to make sure "this" gets destructed on the main thread, as the subscription contains a tls_ instance. Capturing "this" in the complete_cb of runOnAllThreads makes sure that "*this" is alive after every first-lambda is called, and the held "*this" is posted back to main thread. If we capture it in the first lambda, the shared_this may get destructed in a worker thread, cause an assertion failure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make this more explicit in the comment? This is a subtle correctness condition, but I think you are right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Comment updated! |
||
} | ||
|
@@ -321,7 +321,6 @@ class ConfigSubscriptionInstance : public ConfigSubscriptionCommonBase { | |
class DeltaConfigSubscriptionInstance : public ConfigSubscriptionCommonBase { | ||
protected: | ||
using ConfigSubscriptionCommonBase::ConfigSubscriptionCommonBase; | ||
~DeltaConfigSubscriptionInstance() override = default; | ||
|
||
/** | ||
* Must be called by the derived class' constructor. | ||
|
@@ -344,8 +343,6 @@ class DeltaConfigSubscriptionInstance : public ConfigSubscriptionCommonBase { | |
*/ | ||
class MutableConfigProviderCommonBase : public ConfigProvider { | ||
public: | ||
~MutableConfigProviderCommonBase() override = default; | ||
|
||
// Envoy::Config::ConfigProvider | ||
SystemTime lastUpdated() const override { return subscription_->lastUpdated(); } | ||
ApiType apiType() const override { return api_type_; } | ||
|
@@ -384,8 +381,6 @@ class MutableConfigProviderCommonBase : public ConfigProvider { | |
*/ | ||
class ConfigProviderManagerImplBase : public ConfigProviderManager, public Singleton::Instance { | ||
public: | ||
~ConfigProviderManagerImplBase() override = default; | ||
|
||
/** | ||
* This is invoked by the /config_dump admin handler. | ||
* @return ProtobufTypes::MessagePtr the config dump proto corresponding to the associated | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this top-level and commented, rather than part of the function signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to do this one :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Sorry I missed this one earlier.