-
Notifications
You must be signed in to change notification settings - Fork 5.5k
config: fix update empty stat for eds #4276
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
Changes from 4 commits
4a29d7a
ecc6188
981914f
e2c49d9
d8c8196
f51d592
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 |
|---|---|---|
|
|
@@ -206,6 +206,9 @@ void GrpcMuxImpl::onReceiveMessage(std::unique_ptr<envoy::api::v2::DiscoveryResp | |
| resources.emplace(resource_name, resource); | ||
| } | ||
| for (auto watch : api_state_[type_url].watches_) { | ||
| // onConfigUpdate should be called in all cases for single watch xDS (Cluster and Listener) | ||
| // even if the message does not have resources so that update_empty stat is properly | ||
| // incremented. | ||
| if (watch->resources_.empty()) { | ||
|
Contributor
Author
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. @htuch single watch xDS case is already handled here. So just added a comment to be clear. Also added a test which validates that. |
||
| watch->callbacks_.onConfigUpdate(message->resources(), message->version_info()); | ||
| continue; | ||
|
|
@@ -217,7 +220,11 @@ void GrpcMuxImpl::onReceiveMessage(std::unique_ptr<envoy::api::v2::DiscoveryResp | |
| found_resources.Add()->MergeFrom(it->second); | ||
| } | ||
| } | ||
| watch->callbacks_.onConfigUpdate(found_resources, message->version_info()); | ||
| // onConfigUpdate should be called only on watches(clusters/routes) that have updates in the | ||
| // message. | ||
| if (found_resources.size() > 0) { | ||
| watch->callbacks_.onConfigUpdate(found_resources, message->version_info()); | ||
| } | ||
| } | ||
| // TODO(mattklein123): In the future if we start tracking per-resource versions, we would do | ||
| // that tracking here. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,8 +198,6 @@ TEST_F(GrpcMuxImplTest, TypeUrlMismatch) { | |
| // Validate behavior when watches has an unknown resource name. | ||
| TEST_F(GrpcMuxImplTest, WildcardWatch) { | ||
| setup(); | ||
|
|
||
| InSequence s; | ||
|
Member
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. Why remove this?
Contributor
Author
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. Sorry. This was not intentional. Some merge issue master looks like |
||
| const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment; | ||
| auto foo_sub = grpc_mux_->subscribe(type_url, {}, callbacks_); | ||
| EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_)); | ||
|
|
@@ -231,7 +229,6 @@ TEST_F(GrpcMuxImplTest, WildcardWatch) { | |
| // Validate behavior when watches specify resources (potentially overlapping). | ||
| TEST_F(GrpcMuxImplTest, WatchDemux) { | ||
| setup(); | ||
|
|
||
| InSequence s; | ||
| const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment; | ||
| NiceMock<MockGrpcMuxCallbacks> foo_callbacks; | ||
|
|
@@ -251,9 +248,6 @@ TEST_F(GrpcMuxImplTest, WatchDemux) { | |
| envoy::api::v2::ClusterLoadAssignment load_assignment; | ||
| load_assignment.set_cluster_name("x"); | ||
| response->add_resources()->PackFrom(load_assignment); | ||
| EXPECT_CALL(bar_callbacks, onConfigUpdate(_, "1")) | ||
|
Member
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. Could make this a |
||
| .WillOnce(Invoke([](const Protobuf::RepeatedPtrField<ProtobufWkt::Any>& resources, | ||
| const std::string&) { EXPECT_TRUE(resources.empty()); })); | ||
| EXPECT_CALL(foo_callbacks, onConfigUpdate(_, "1")) | ||
| .WillOnce( | ||
| Invoke([&load_assignment](const Protobuf::RepeatedPtrField<ProtobufWkt::Any>& resources, | ||
|
|
@@ -311,6 +305,31 @@ TEST_F(GrpcMuxImplTest, WatchDemux) { | |
| expectSendMessage(type_url, {}, "2"); | ||
| } | ||
|
|
||
| // Validate behavior when Cluster sends empty updates. | ||
|
Member
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 would phrase it a bit differently; we want one test when there is a single watcher with empty updates and another test when we have multiple watchers with an empty update. |
||
| TEST_F(GrpcMuxImplTest, WatchClusterWithEmptyUpdates) { | ||
| setup(); | ||
| const std::string& type_url = Config::TypeUrl::get().Cluster; | ||
| NiceMock<MockGrpcMuxCallbacks> foo_callbacks; | ||
| auto foo_sub = grpc_mux_->subscribe(type_url, {}, foo_callbacks); | ||
|
|
||
| EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_)); | ||
| expectSendMessage(type_url, {}, ""); | ||
| grpc_mux_->start(); | ||
|
|
||
| { | ||
| std::unique_ptr<envoy::api::v2::DiscoveryResponse> response( | ||
| new envoy::api::v2::DiscoveryResponse()); | ||
| response->set_type_url(type_url); | ||
| response->set_version_info("1"); | ||
| // Validate that onConfigUpdate is called with empty resources. | ||
| EXPECT_CALL(foo_callbacks, onConfigUpdate(_, "1")) | ||
| .WillOnce(Invoke([](const Protobuf::RepeatedPtrField<ProtobufWkt::Any>& resources, | ||
| const std::string&) { EXPECT_TRUE(resources.empty()); })); | ||
| expectSendMessage(type_url, {}, "1"); | ||
| grpc_mux_->onReceiveMessage(std::move(response)); | ||
| } | ||
| } | ||
|
|
||
| // Verifies that warning messages get logged when Envoy detects too many requests. | ||
| TEST_F(GrpcMuxImplTest, TooManyRequests) { | ||
| setup(); | ||
|
|
||
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.
properly incremented and state-of-the-world semantics are maintained.