xDS: adds a callback for resource unsubscription to the xDS config tracker#45898
xDS: adds a callback for resource unsubscription to the xDS config tracker#45898birenroy wants to merge 14 commits into
Conversation
|
/assign @adisuissa |
| return resource_name; | ||
| }); | ||
| // Computes the removed resources. | ||
| std::set<std::string> removed_resources; |
There was a problem hiding this comment.
will it make sense to only compute the diffs if eds_resources_cache_ is used or there is an xds_config_tracker_ defined?
| return; | ||
| } | ||
| std::vector<absl::string_view> truly_removed; | ||
| for (const auto& resource_name : resources_to_remove) { |
There was a problem hiding this comment.
please add a comment that this filtering is because some resources weren't subscribed to previously.
There was a problem hiding this comment.
I'm not sure I understand the proposed comment. I thought this code is trying to determine the set of resources that are no longer present in any watch.
I believe the idea is that if our Envoy receives a SRDS removal, for example, then it will drop a corresponding RDS subscription. The RDS object was subscribed to, but as a "dependent" resource, removal happens on the client side, without the xDS server explicitly indicating a removal.
| if (watch == this) { | ||
| continue; | ||
| } | ||
| if (watch->resources_.find(resource_name) != watch->resources_.end()) { |
There was a problem hiding this comment.
Does this work for wildcard resources (say CDS)? IS there a test for it?
There was a problem hiding this comment.
I added tests showing that wildcard resources don't get quite the same behavior. I think this is fine for now, unless someone needs the wildcard-derived resources tracked.
|
|
||
| // 6. Verify tracker callback was called. | ||
| test_server_->waitForCounter("test_xds_tracker.on_resource_unsubscribed", Eq(1)); | ||
| EXPECT_EQ(1, test_server_->counter("test_xds_tracker.on_resource_unsubscribed")->value()); |
There was a problem hiding this comment.
Shouldn't this be equal to 2 (one for the cluster and one for the endpoint)?
There was a problem hiding this comment.
The cluster is explicitly removed (as per the comment for step 5). Explicit server-side removals are already visible to an xDS config tracker, and do not need to be communicated through onResourceUnsubscribed().
birenroy
left a comment
There was a problem hiding this comment.
Thanks for the review, please take another look.
| return resource_name; | ||
| }); | ||
| // Computes the removed resources. | ||
| std::set<std::string> removed_resources; |
| return; | ||
| } | ||
| std::vector<absl::string_view> truly_removed; | ||
| for (const auto& resource_name : resources_to_remove) { |
There was a problem hiding this comment.
I'm not sure I understand the proposed comment. I thought this code is trying to determine the set of resources that are no longer present in any watch.
I believe the idea is that if our Envoy receives a SRDS removal, for example, then it will drop a corresponding RDS subscription. The RDS object was subscribed to, but as a "dependent" resource, removal happens on the client side, without the xDS server explicitly indicating a removal.
|
|
||
| // 6. Verify tracker callback was called. | ||
| test_server_->waitForCounter("test_xds_tracker.on_resource_unsubscribed", Eq(1)); | ||
| EXPECT_EQ(1, test_server_->counter("test_xds_tracker.on_resource_unsubscribed")->value()); |
There was a problem hiding this comment.
The cluster is explicitly removed (as per the comment for step 5). Explicit server-side removals are already visible to an xDS config tracker, and do not need to be communicated through onResourceUnsubscribed().
| if (watch == this) { | ||
| continue; | ||
| } | ||
| if (watch->resources_.find(resource_name) != watch->resources_.end()) { |
There was a problem hiding this comment.
I added tests showing that wildcard resources don't get quite the same behavior. I think this is fine for now, unless someone needs the wildcard-derived resources tracked.
…legate Add integration tests for XdsConfigTracker and XdsResourcesDelegate in both SotW (GrpcMuxImpl) and Delta (NewGrpcMuxImpl) implementations. Verify that: - onConfigAccepted/onConfigRejected are called on XdsConfigTracker. - getResources/onConfigUpdated/onResourceLoadFailed are called on XdsResourcesDelegate (SotW only). TAG=agy CONV=b942214e-2f01-4571-9478-b3eda0877a4c Signed-off-by: Biren Roy <birenroy@google.com>
…d mocks Move MockXdsConfigTracker and MockXdsResourcesDelegate from local test files to test/mocks/config/mocks.h to allow reuse and avoid duplication. Update BUILD dependencies accordingly. TAG=agy CONV=b942214e-2f01-4571-9478-b3eda0877a4c Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
Signed-off-by: Biren Roy <birenroy@google.com>
…tests Signed-off-by: Biren Roy <birenroy@google.com>
…ption Signed-off-by: Biren Roy <birenroy@google.com>
4f89e64 to
7fd4841
Compare
|
Please review #45930 first; it adds some unit test coverage for existing code. |
This conveys information about resources for which the Envoy takes client-side action to unsubscribe, and there is no server-side removal transmitted. This closes a small gap in xDS visibility for config tracker implementations.
I know the implementation in
notifyUnsubscribedResources()is potentially expensive, but it is similar to the existingremoveResourcesFromCache(), and only affects cases wherexds_config_tracker_is present. I have another PR in progress to improve the efficiency of both cases.This PR was generated with the assistance of the Gemini AI model. I have read and understand the code diffs, and have made some manual tweaks.
Commit Message: adds a callback for resource unsubscription to the xDS config tracker
Additional Description:
Risk Level: low
Testing: ran unit and integration tests locally
Docs Changes:
Release Notes:
Platform Specific Features: