From 5c242f0577d4609464b25d9112a50d215abf680e Mon Sep 17 00:00:00 2001 From: Donna Dionne Date: Sun, 13 Sep 2020 12:51:37 -0700 Subject: [PATCH] Fixing flake in DeadUpdate It is observed that ADS is shutdown, but it's possible that a request still comes in. This request should not update the ADS resource_type_response_state_ as they were cleared by the shutdown. This fix ensures this. --- test/cpp/end2end/xds_end2end_test.cc | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 8d771d25981..57d1430a478 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -766,19 +766,22 @@ class AdsServiceImpl : public std::enable_shared_from_this { request.DebugString().c_str()); const std::string v3_resource_type = TypeUrlToV3(request.type_url()); - // Identify ACK and NACK by looking for version information and - // comparing it to nonce (this server ensures they are always set - // to the same in a response.) - if (!request.response_nonce().empty()) { - parent_->resource_type_response_state_[v3_resource_type].state = - (!request.version_info().empty() && - request.version_info() == request.response_nonce()) - ? ResponseState::ACKED - : ResponseState::NACKED; - } - if (request.has_error_detail()) { - parent_->resource_type_response_state_[v3_resource_type] - .error_message = request.error_detail().message(); + // As long as we are not in shutdown, identify ACK and NACK by + // looking for version information and comparing it to nonce (this + // server ensures they are always set to the same in a response.) + auto it = + parent_->resource_type_response_state_.find(v3_resource_type); + if (it != parent_->resource_type_response_state_.end()) { + if (!request.response_nonce().empty()) { + it->second.state = + (!request.version_info().empty() && + request.version_info() == request.response_nonce()) + ? ResponseState::ACKED + : ResponseState::NACKED; + } + if (request.has_error_detail()) { + it->second.error_message = request.error_detail().message(); + } } // As long as the test did not tell us to ignore this type of // request, we will loop through all resources to: