From 3ce93f3795455aad4d32a51b3ec6ba4161f7be92 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 15 Jul 2020 12:48:52 -0700 Subject: [PATCH] Include the target name in c-ares and native DNS summary error messages --- .../resolver/dns/c_ares/dns_resolver_ares.cc | 7 +++++-- .../client_channel/resolver/dns/native/dns_resolver.cc | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 781941bdbb8..49e37c5e8ec 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -25,6 +25,7 @@ #include #include "absl/container/inlined_vector.h" +#include "absl/strings/str_cat.h" #include #include @@ -370,9 +371,11 @@ void AresDnsResolver::OnResolvedLocked(grpc_error* error) { } else { GRPC_CARES_TRACE_LOG("resolver:%p dns resolution failed: %s", this, grpc_error_string(error)); + std::string error_message = + absl::StrCat("DNS resolution failed for service: ", name_to_resolve_); result_handler()->ReturnError(grpc_error_set_int( - GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( - "DNS resolution failed", &error, 1), + GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(error_message.c_str(), + &error, 1), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE)); // Set retry timer. grpc_millis next_try = backoff_.NextAttemptTime(); diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index e98a3e6d167..3b0c042d292 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -22,6 +22,8 @@ #include #include +#include "absl/strings/str_cat.h" + #include #include #include @@ -195,9 +197,11 @@ void NativeDnsResolver::OnResolvedLocked(grpc_error* error) { gpr_log(GPR_INFO, "dns resolution failed (will retry): %s", grpc_error_string(error)); // Return transient error. + std::string error_message = + absl::StrCat("DNS resolution failed for service: ", name_to_resolve_); result_handler()->ReturnError(grpc_error_set_int( - GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( - "DNS resolution failed", &error, 1), + GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(error_message.c_str(), + &error, 1), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE)); // Set up for retry. grpc_millis next_try = backoff_.NextAttemptTime();