Skip to content

Commit

Permalink
odcds: resolve subscription issue when managing multiple upstream end…
Browse files Browse the repository at this point in the history
…points

Signed-off-by: whutwhu <[email protected]>
  • Loading branch information
whutwhu committed Oct 10, 2024
1 parent 55b0fc4 commit 1f9825d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions source/common/upstream/od_cds_api_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void OdCdsApiImpl::sendAwaiting() {
// used any more.
ENVOY_LOG(debug, "odcds: sending request for awaiting cluster names {}",
fmt::join(awaiting_names_, ", "));
subscription_->requestOnDemandUpdate(awaiting_names_);
subscription_->updateResourceInterest(awaiting_names_);
awaiting_names_.clear();
}

Expand All @@ -108,7 +108,7 @@ void OdCdsApiImpl::updateOnDemand(std::string cluster_name) {

case StartStatus::InitialFetchDone:
ENVOY_LOG(trace, "odcds: requesting for cluster name {}", cluster_name);
subscription_->requestOnDemandUpdate({std::move(cluster_name)});
subscription_->updateResourceInterest({std::move(cluster_name)});
return;
}
PANIC("corrupt enum");
Expand Down
12 changes: 6 additions & 6 deletions test/common/upstream/od_cds_api_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEST_F(OdCdsApiImplTest, FollowingClusterNamesHitAwaitingList) {
InSequence s;

EXPECT_CALL(*cm_.subscription_factory_.subscription_, start(ElementsAre("fake_cluster")));
EXPECT_CALL(*cm_.subscription_factory_.subscription_, requestOnDemandUpdate(_)).Times(0);
EXPECT_CALL(*cm_.subscription_factory_.subscription_, updateResourceInterest(_)).Times(0);
odcds_->updateOnDemand("fake_cluster");
odcds_->updateOnDemand("another_cluster");
}
Expand All @@ -70,7 +70,7 @@ TEST_F(OdCdsApiImplTest, AwaitingListIsProcessedOnConfigUpdate) {
const auto decoded_resources = TestUtility::decodeResources({cluster});
EXPECT_CALL(
*cm_.subscription_factory_.subscription_,
requestOnDemandUpdate(UnorderedElementsAre("another_cluster_1", "another_cluster_2")));
updateResourceInterest(UnorderedElementsAre("another_cluster_1", "another_cluster_2")));
ASSERT_TRUE(odcds_callbacks_->onConfigUpdate(decoded_resources.refvec_, {}, "0").ok());
}

Expand All @@ -85,7 +85,7 @@ TEST_F(OdCdsApiImplTest, AwaitingListIsProcessedOnConfigUpdateFailed) {

EXPECT_CALL(
*cm_.subscription_factory_.subscription_,
requestOnDemandUpdate(UnorderedElementsAre("another_cluster_1", "another_cluster_2")));
updateResourceInterest(UnorderedElementsAre("another_cluster_1", "another_cluster_2")));
odcds_callbacks_->onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason::FetchTimedout,
nullptr);
}
Expand All @@ -101,7 +101,7 @@ TEST_F(OdCdsApiImplTest, AwaitingListIsProcessedOnceOnly) {

EXPECT_CALL(
*cm_.subscription_factory_.subscription_,
requestOnDemandUpdate(UnorderedElementsAre("another_cluster_1", "another_cluster_2")));
updateResourceInterest(UnorderedElementsAre("another_cluster_1", "another_cluster_2")));
odcds_callbacks_->onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason::FetchTimedout,
nullptr);
odcds_callbacks_->onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason::FetchTimedout,
Expand All @@ -114,7 +114,7 @@ TEST_F(OdCdsApiImplTest, NothingIsRequestedOnEmptyAwaitingList) {

odcds_->updateOnDemand("fake_cluster");

EXPECT_CALL(*cm_.subscription_factory_.subscription_, requestOnDemandUpdate(_)).Times(0);
EXPECT_CALL(*cm_.subscription_factory_.subscription_, updateResourceInterest(_)).Times(0);
odcds_callbacks_->onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason::FetchTimedout,
nullptr);
}
Expand All @@ -130,7 +130,7 @@ TEST_F(OdCdsApiImplTest, OnDemandUpdateIsRequestedAfterInitialFetch) {
const auto decoded_resources = TestUtility::decodeResources({cluster});
ASSERT_TRUE(odcds_callbacks_->onConfigUpdate(decoded_resources.refvec_, {}, "0").ok());
EXPECT_CALL(*cm_.subscription_factory_.subscription_,
requestOnDemandUpdate(UnorderedElementsAre("another_cluster")));
updateResourceInterest(UnorderedElementsAre("another_cluster")));
odcds_->updateOnDemand("another_cluster");
}

Expand Down

0 comments on commit 1f9825d

Please sign in to comment.