xDS: improve status messages from xDS resolver failures (#29975)

pull/29869/head
Mark D. Roth 3 years ago committed by GitHub
parent c805c4e2d4
commit f12972506e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  2. 43
      test/cpp/end2end/xds/xds_core_end2end_test.cc
  3. 15
      test/cpp/end2end/xds/xds_csds_end2end_test.cc
  4. 5
      test/cpp/end2end/xds/xds_routing_end2end_test.cc

@ -187,7 +187,9 @@ class XdsResolver : public Resolver {
Ref().release(); // ref held by lambda
resolver_->work_serializer_->Run(
[this]() {
resolver_->OnResourceDoesNotExist();
resolver_->OnResourceDoesNotExist(
absl::StrCat(resolver_->lds_resource_name_,
": xDS listener resource does not exist"));
Unref();
},
DEBUG_LOCATION);
@ -226,7 +228,9 @@ class XdsResolver : public Resolver {
Ref().release(); // ref held by lambda
resolver_->work_serializer_->Run(
[this]() {
resolver_->OnResourceDoesNotExist();
resolver_->OnResourceDoesNotExist(absl::StrCat(
resolver_->route_config_name_,
": xDS route configuration resource does not exist"));
Unref();
},
DEBUG_LOCATION);
@ -357,7 +361,7 @@ class XdsResolver : public Resolver {
void OnListenerUpdate(XdsListenerResource listener);
void OnRouteConfigUpdate(XdsRouteConfigResource rds_update);
void OnError(absl::string_view context, absl::Status status);
void OnResourceDoesNotExist();
void OnResourceDoesNotExist(std::string context);
absl::StatusOr<RefCountedPtr<ServiceConfig>> CreateServiceConfig();
void GenerateResult();
@ -977,7 +981,7 @@ void XdsResolver::OnError(absl::string_view context, absl::Status status) {
result_handler_->ReportResult(std::move(result));
}
void XdsResolver::OnResourceDoesNotExist() {
void XdsResolver::OnResourceDoesNotExist(std::string context) {
gpr_log(GPR_ERROR,
"[xds_resolver %p] LDS/RDS resource does not exist -- clearing "
"update and returning empty service config",
@ -991,6 +995,7 @@ void XdsResolver::OnResourceDoesNotExist() {
grpc_error_handle error = GRPC_ERROR_NONE;
result.service_config = ServiceConfigImpl::Create(args_, "{}", &error);
GPR_ASSERT(*result.service_config != nullptr);
result.resolution_note = std::move(context);
result.args = grpc_channel_args_copy(args_);
result_handler_->ReportResult(std::move(result));
}

@ -395,20 +395,18 @@ INSTANTIATE_TEST_SUITE_P(
TEST_P(TimeoutTest, LdsServerIgnoresRequest) {
balancer_->ads_service()->IgnoreResourceType(kLdsTypeUrl);
CheckRpcSendFailure(
DEBUG_LOCATION, StatusCode::UNAVAILABLE,
// TODO(roth): Improve this error as part of
// https://github.com/grpc/grpc/issues/22883.
"empty address list: ", RpcOptions().set_timeout_ms(4000));
CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
absl::StrCat("empty address list: ", kServerName,
": xDS listener resource does not exist"),
RpcOptions().set_timeout_ms(4000));
}
TEST_P(TimeoutTest, LdsResourceNotPresentInRequest) {
balancer_->ads_service()->UnsetResource(kLdsTypeUrl, kServerName);
CheckRpcSendFailure(
DEBUG_LOCATION, StatusCode::UNAVAILABLE,
// TODO(roth): Improve this error as part of
// https://github.com/grpc/grpc/issues/22883.
"empty address list: ", RpcOptions().set_timeout_ms(4000));
CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
absl::StrCat("empty address list: ", kServerName,
": xDS listener resource does not exist"),
RpcOptions().set_timeout_ms(4000));
}
TEST_P(TimeoutTest, LdsSecondResourceNotPresentInRequest) {
@ -434,18 +432,17 @@ TEST_P(TimeoutTest, LdsSecondResourceNotPresentInRequest) {
SendRpcMethod(stub2.get(), rpc_options, &context, request, &response);
EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code());
EXPECT_THAT(status.error_message(),
// TODO(roth): Improve this error as part of
// https://github.com/grpc/grpc/issues/22883.
"empty address list: ");
absl::StrCat("empty address list: ", kNewServerName,
": xDS listener resource does not exist"));
}
TEST_P(TimeoutTest, RdsServerIgnoresRequest) {
balancer_->ads_service()->IgnoreResourceType(kRdsTypeUrl);
CheckRpcSendFailure(
DEBUG_LOCATION, StatusCode::UNAVAILABLE,
// TODO(roth): Improve this error as part of
// https://github.com/grpc/grpc/issues/22883.
"empty address list: ", RpcOptions().set_timeout_ms(4000));
absl::StrCat("empty address list: ", kDefaultRouteConfigurationName,
": xDS route configuration resource does not exist"),
RpcOptions().set_timeout_ms(4000));
}
TEST_P(TimeoutTest, RdsResourceNotPresentInRequest) {
@ -453,9 +450,9 @@ TEST_P(TimeoutTest, RdsResourceNotPresentInRequest) {
kDefaultRouteConfigurationName);
CheckRpcSendFailure(
DEBUG_LOCATION, StatusCode::UNAVAILABLE,
// TODO(roth): Improve this error as part of
// https://github.com/grpc/grpc/issues/22883.
"empty address list: ", RpcOptions().set_timeout_ms(4000));
absl::StrCat("empty address list: ", kDefaultRouteConfigurationName,
": xDS route configuration resource does not exist"),
RpcOptions().set_timeout_ms(4000));
}
TEST_P(TimeoutTest, RdsSecondResourceNotPresentInRequest) {
@ -492,10 +489,10 @@ TEST_P(TimeoutTest, RdsSecondResourceNotPresentInRequest) {
auto status =
SendRpcMethod(stub2.get(), rpc_options, &context, request, &response);
EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code());
EXPECT_EQ(status.error_message(),
// TODO(roth): Improve this error as part of
// https://github.com/grpc/grpc/issues/22883.
"empty address list: ");
EXPECT_THAT(
status.error_message(),
absl::StrCat("empty address list: ", kNewRouteConfigName,
": xDS route configuration resource does not exist"));
}
TEST_P(TimeoutTest, CdsServerIgnoresRequest) {

@ -634,11 +634,10 @@ INSTANTIATE_TEST_SUITE_P(
TEST_P(CsdsShortAdsTimeoutTest, XdsConfigDumpListenerDoesNotExist) {
int kTimeoutMillisecond = 1000000; // 1000s wait for the transient failure.
balancer_->ads_service()->UnsetResource(kLdsTypeUrl, kServerName);
CheckRpcSendFailure(
DEBUG_LOCATION, StatusCode::UNAVAILABLE,
// TODO(roth): Improve this error as part of
// https://github.com/grpc/grpc/issues/22883.
"empty address list: ", RpcOptions().set_timeout_ms(kTimeoutMillisecond));
CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
absl::StrCat("empty address list: ", kServerName,
": xDS listener resource does not exist"),
RpcOptions().set_timeout_ms(kTimeoutMillisecond));
auto csds_response = FetchCsdsResponse();
EXPECT_THAT(csds_response.config(0).generic_xds_configs(),
::testing::Contains(EqGenericXdsConfig(
@ -653,9 +652,9 @@ TEST_P(CsdsShortAdsTimeoutTest, XdsConfigDumpRouteConfigDoesNotExist) {
kDefaultRouteConfigurationName);
CheckRpcSendFailure(
DEBUG_LOCATION, StatusCode::UNAVAILABLE,
// TODO(roth): Improve this error as part of
// https://github.com/grpc/grpc/issues/22883.
"empty address list: ", RpcOptions().set_timeout_ms(kTimeoutMillisecond));
absl::StrCat("empty address list: ", kDefaultRouteConfigurationName,
": xDS route configuration resource does not exist"),
RpcOptions().set_timeout_ms(kTimeoutMillisecond));
auto csds_response = FetchCsdsResponse();
EXPECT_THAT(
csds_response.config(0).generic_xds_configs(),

@ -478,9 +478,8 @@ TEST_P(LdsDeletionTest, ListenerDeleted) {
if (result.status.ok()) return true; // Keep going.
EXPECT_EQ(result.status.error_code(), StatusCode::UNAVAILABLE);
EXPECT_EQ(result.status.error_message(),
// TODO(roth): Improve this error message as part of
// https://github.com/grpc/grpc/issues/22883.
"empty address list: ");
absl::StrCat("empty address list: ", kServerName,
": xDS listener resource does not exist"));
return false;
});
// Make sure we ACK'ed the update.

Loading…
Cancel
Save