config: fix a bug where the on demand subscription not works#46216
config: fix a bug where the on demand subscription not works#46216wbpcode wants to merge 3 commits into
Conversation
Signed-off-by: wbpcode <wbphub@gmail.com>
Signed-off-by: wbpcode <wbphub@gmail.com>
| if (options.use_namespace_matching_) { | ||
| // This is to prevent sending out of requests that contain prefixes instead of resource names | ||
| sub->second->sub_state_.updateSubscriptionInterest({}, {}); | ||
| } else { | ||
| sub->second->sub_state_.updateSubscriptionInterest(added_removed.added_, | ||
| added_removed.removed_); | ||
| } | ||
| sub->second->sub_state_.updateSubscriptionInterest(added_removed.added_, added_removed.removed_); |
There was a problem hiding this comment.
The use_namespace_matching_ here make it's impossible to subscribe other resource in the start() and update interest method because they all will be cleaned.
Now, we will always respect the resources set provided by the start() and updateResourceInterest() here, and use the accept() to customize the resource routing.
|
Also related to #44129 |
adisuissa
left a comment
There was a problem hiding this comment.
Thanks for raising the bug, and proposing a fix.
To the best of my understanding, w.r.t. 'append', the proposed design essentially introduces the on-demand concept into the GrpcMuxWatch, which may weaken the abstraction and encapsulation of the on-demand concept. I believe the proposed design leaks that concept into the GrpcMux (similar to how the namespace-matching is a leak of the watched resources, which as you are pointing out is a problem). Note that Envoy already supports multiple GrpcSubscription object over the same GrpcMux (so the watch is updated correctly while there are dynamic "additions" to the watched objects).
Assuming that on-demand is for a named resource, I believe the issue can also be solved by introducing multiple GrpcSubscription objects (for each VDHS resource that needs to be fetched), that will be fetched over the same GrpcMux.
W.r.t. 'accept' I agree that there is an issue with VHDS. I think the issue is even a bit more challenging, for example, say there are 2 routes '/shared/prefix/route_1', and '/shared/prefix', which subscriptions would a VHDS for the two different routes will be invoked once a response comes back. In general, this is a challenge with wildcard subscriptions and it would be good to get a good solution for this. I'm not sure if the proposed aliasing solution is the right thing to do, but it seems to be a bit more explicit - telling the xDS system, what to 'accept' by defining it in the resource the client subscribes to.
| [this]() { | ||
| subscription_->start( | ||
| {config_update_info_->protobufConfigurationCast().name()}); | ||
| // Start with no concrete subscription; virtual hosts are fetched on demand. |
There was a problem hiding this comment.
Is this a breaking change with the VHDS default wildcard subscription?
There was a problem hiding this comment.
Nope, this PR didn't change any behavior. The VHDS worked in a special way before.
It will specific a route configuration name (for example rc) in the start() But this rc will not be sent out because the use_namespace_matching won't add anything to the subscription state. See the #46216 (comment)
Then this rc will be used to match received resources based on prefix matching.
For control plane's perspective, nothing is changed.
Wouldn't this be much more expensive than just adding resources to the watch? we could be talking of many thousands of resources. |
Really depends on whether there's support for subscription removal or not. |
I don't think this is actual problem. Note, we have supported
Every GrpcSubscription for single resource (like a domain) is much more heavy if there are thousands resources. And if there are multiple resources/subscriptions, we still need to abstract a layer to manager all these subscriptions, like the I don't think multiple subscription is a bad idea. But with our current subscription and watch map's design, after this fix, a single subscription could manage a set of resource very well, and more efficient, easier to use. I guess there is no strong reason to use multiple subscriptions' solution.
Our current underlying subscription and watch map design have supported the resource removal well. To expose a In short conclusion, our current subscription and watch map are well designed for multiple resources in same subscription. And it match the actual requirement (one observer, multiple resources) very well. Fix it and enhance it should bring us more benefit rather than to deprecate it. |
In very long time, we still need to handle canonical xDS. So, I guess the
Basically, |
How does it handle a removal of a subscription from the watcher?
Why isn't there a requirement for removal? What happens if the listener that subscribed to the VHDS resource is removed?
The breaking of that abstraction is one of the things that caused issues with on-demand out-of-sync subscriptions. |
When a subscription is removed, it will be removed from the watch map. For specific resource, if the removed subscription is only one to subscribe the resource, the resource will be removed. If there are other subscriptions want this resource, resource will be kept. Yeah, watch map have tracked everything. Every subscription's resource list and every resource is subscribed by which subscriptions. |
Sorry, I meant to remove a specific resource from a subscription. Until now, no related requirements. All your referred are cases to remove whole subscription. For these cases, they will be removed correctly as I described in the #46216 (comment) And you are right, I only use VHDS as an example. This is general problem, and this PR is also a general fix for all xDS-types (i mean CDS/LDS/... and so on, not means file/rest/...). |
Sorry. I didn't get you here. Could you explain a little more about the |
|
BTW, to avoid there is any information gap, when I say |
|
After a rethinking and discuss with AI, did you mean the current design shouldn't leak the gRPC implementation detail like If you mean that, I guess it's too late to discuss that. GRPC is special from start. For example, the file xds even cannot support a the The next generation should is the xdstp, but it's another topic. |
|
/coverage |
|
Coverage for this Pull Request will be rendered here: https://storage.googleapis.com/envoy-cncf-pr/46216/coverage/index.html For comparison, current coverage on https://storage.googleapis.com/envoy-cncf-postsubmit/main/coverage/index.html The coverage results are (re-)rendered each time the CI |
Signed-off-by: wbpcode <wbphub@gmail.com>
Commit Message: config: fix a bug where the on demand subscription not works
Additional Description:
In the previous xds implementation, the
requestOnDemandUpdate()will update the resources in the discovery request but doesn't update the watch self which make the responded resource will be silently dropped.The VHDS works because it use a namespace matching to match all resource with same prefix. The
use_namespace_matchingself is subscription level option, but will be affected all subscriptions under the same type_url. So, it more like a hack.The ODCDS is a problem. The integration show it can never works correctly. 😞
Anyway, this PR fixed these problems by:
accept()method to replace theuse_namespace_matchingwhich is more clearly.Risk Level: mid, core code change.
Testing: unit, integration.
Docs Changes: n/a.
Release Notes: added.
Platform Specific Features: n/a.