Skip to content
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: allow empty delta update #12699

Merged
merged 2 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions source/common/config/watch_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ void WatchMap::onConfigUpdate(
}
cur_watch->callbacks_.onConfigUpdate({}, resource_to_remove, system_version_info);
}
// notify empty update
if (added_resources.empty() && removed_resources.empty()) {
for (auto& cur_watch : wildcard_watches_) {
cur_watch->callbacks_.onConfigUpdate({}, {}, system_version_info);
}
}
}

void WatchMap::onConfigUpdateFailed(ConfigUpdateFailureReason reason, const EnvoyException* e) {
Expand Down
3 changes: 2 additions & 1 deletion test/common/config/new_grpc_mux_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ TEST_F(NewGrpcMuxImplTest, DiscoveryResponseNonexistentSub) {
std::make_unique<envoy::service::discovery::v3::DeltaDiscoveryResponse>();
unexpected_response->set_type_url(type_url);
unexpected_response->set_system_version_info("0");
EXPECT_CALL(callbacks_, onConfigUpdate(_, _, "0")).Times(0);
// empty response should call onConfigUpdate on wildcard watch
EXPECT_CALL(callbacks_, onConfigUpdate(_, _, "0")).Times(1);
grpc_mux_->onDiscoveryResponse(std::move(unexpected_response), control_plane_stats_);
}
{
Expand Down
6 changes: 6 additions & 0 deletions test/common/config/watch_map_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ TEST(WatchMapTest, Basic) {
WatchMap watch_map;
Watch* watch = watch_map.addWatch(callbacks, resource_decoder);

{
// nothing is interested, so become wildcard watch
// should callback with empty resource
expectDeltaAndSotwUpdate(callbacks, {}, {}, "version1");
doDeltaAndSotwUpdate(watch_map, {}, {}, "version1");
}
{
// The watch is interested in Alice and Bob...
std::set<std::string> update_to({"alice", "bob"});
Expand Down