diff --git a/src/core/ext/xds/xds_client.cc b/src/core/ext/xds/xds_client.cc index 83d6f9b84a2..7740712eda1 100644 --- a/src/core/ext/xds/xds_client.cc +++ b/src/core/ext/xds/xds_client.cc @@ -1022,6 +1022,13 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate( const std::string& cluster_name = p.first; if (cds_update_map.find(cluster_name) == cds_update_map.end()) { ClusterState& cluster_state = xds_client()->cluster_map_[cluster_name]; + // If the resource was newly requested but has not yet been received, + // we don't want to generate an error for the watchers, because this CDS + // response may be in reaction to an earlier request that did not yet + // request the new resource, so its absence from the response does not + // necessarily indicate that the resource does not exist. + // For that case, we rely on the request timeout instead. + if (!cluster_state.update.has_value()) continue; cluster_state.update.reset(); for (const auto& p : cluster_state.watchers) { p.first->OnResourceDoesNotExist(); diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 0fb9bff7bc5..00a24c61f87 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -1545,6 +1545,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam { "Performed %d warm up requests against the backends. " "%d succeeded, %d failed, %d dropped.", num_total, num_ok, num_failure, num_drops); + EXPECT_EQ(num_failure, 0); return std::make_tuple(num_ok, num_failure, num_drops); }