XdsClient: Generate error message when no supported creds types found.

pull/21875/head
Mark D. Roth 5 years ago
parent 2a7191abe7
commit b5df3ee398
  1. 3
      src/core/ext/filters/client_channel/xds/xds_channel.cc
  2. 4
      src/core/ext/filters/client_channel/xds/xds_channel.h
  3. 9
      src/core/ext/filters/client_channel/xds/xds_channel_secure.cc
  4. 26
      src/core/ext/filters/client_channel/xds/xds_client.cc
  5. 3
      src/core/ext/filters/client_channel/xds/xds_client.h

@ -29,7 +29,8 @@ grpc_channel_args* ModifyXdsChannelArgs(grpc_channel_args* args) {
} }
grpc_channel* CreateXdsChannel(const XdsBootstrap& bootstrap, grpc_channel* CreateXdsChannel(const XdsBootstrap& bootstrap,
const grpc_channel_args& args) { const grpc_channel_args& args,
grpc_error** error) {
if (!bootstrap.server().channel_creds.empty()) return nullptr; if (!bootstrap.server().channel_creds.empty()) return nullptr;
return grpc_insecure_channel_create(bootstrap.server().server_uri.c_str(), return grpc_insecure_channel_create(bootstrap.server().server_uri.c_str(),
&args, nullptr); &args, nullptr);

@ -24,6 +24,7 @@
#include <grpc/impl/codegen/grpc_types.h> #include <grpc/impl/codegen/grpc_types.h>
#include "src/core/ext/filters/client_channel/xds/xds_bootstrap.h" #include "src/core/ext/filters/client_channel/xds/xds_bootstrap.h"
#include "src/core/lib/iomgr/error.h"
namespace grpc_core { namespace grpc_core {
@ -36,7 +37,8 @@ namespace grpc_core {
grpc_channel_args* ModifyXdsChannelArgs(grpc_channel_args* args); grpc_channel_args* ModifyXdsChannelArgs(grpc_channel_args* args);
grpc_channel* CreateXdsChannel(const XdsBootstrap& bootstrap, grpc_channel* CreateXdsChannel(const XdsBootstrap& bootstrap,
const grpc_channel_args& args); const grpc_channel_args& args,
grpc_error** error);
} // namespace grpc_core } // namespace grpc_core

@ -64,7 +64,8 @@ grpc_channel_args* ModifyXdsChannelArgs(grpc_channel_args* args) {
} }
grpc_channel* CreateXdsChannel(const XdsBootstrap& bootstrap, grpc_channel* CreateXdsChannel(const XdsBootstrap& bootstrap,
const grpc_channel_args& args) { const grpc_channel_args& args,
grpc_error** error) {
grpc_channel_credentials* creds = nullptr; grpc_channel_credentials* creds = nullptr;
RefCountedPtr<grpc_channel_credentials> creds_to_unref; RefCountedPtr<grpc_channel_credentials> creds_to_unref;
if (!bootstrap.server().channel_creds.empty()) { if (!bootstrap.server().channel_creds.empty()) {
@ -77,7 +78,11 @@ grpc_channel* CreateXdsChannel(const XdsBootstrap& bootstrap,
break; break;
} }
} }
if (creds == nullptr) return nullptr; if (creds == nullptr) {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"no supported credential types found");
return nullptr;
}
creds_to_unref.reset(creds); creds_to_unref.reset(creds);
} else { } else {
creds = grpc_channel_credentials_find_in_args(&args); creds = grpc_channel_credentials_find_in_args(&args);

@ -472,12 +472,10 @@ grpc_channel_args* BuildXdsChannelArgs(const grpc_channel_args& args) {
} // namespace } // namespace
XdsClient::ChannelState::ChannelState(RefCountedPtr<XdsClient> xds_client, XdsClient::ChannelState::ChannelState(RefCountedPtr<XdsClient> xds_client,
const grpc_channel_args& args) grpc_channel* channel)
: InternallyRefCounted<ChannelState>(&grpc_xds_client_trace), : InternallyRefCounted<ChannelState>(&grpc_xds_client_trace),
xds_client_(std::move(xds_client)) { xds_client_(std::move(xds_client)),
grpc_channel_args* new_args = BuildXdsChannelArgs(args); channel_(channel) {
channel_ = CreateXdsChannel(*xds_client_->bootstrap_, *new_args);
grpc_channel_args_destroy(new_args);
GPR_ASSERT(channel_ != nullptr); GPR_ASSERT(channel_ != nullptr);
StartConnectivityWatchLocked(); StartConnectivityWatchLocked();
} }
@ -1727,18 +1725,24 @@ XdsClient::XdsClient(Combiner* combiner, grpc_pollset_set* interested_parties,
server_name_(server_name), server_name_(server_name),
service_config_watcher_(std::move(watcher)) { service_config_watcher_(std::move(watcher)) {
if (*error != GRPC_ERROR_NONE) { if (*error != GRPC_ERROR_NONE) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { gpr_log(GPR_ERROR, "[xds_client %p] failed to read bootstrap file: %s",
gpr_log(GPR_INFO, "[xds_client %p: failed to read bootstrap file: %s", this, grpc_error_string(*error));
this, grpc_error_string(*error));
}
return; return;
} }
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, "[xds_client %p: creating channel to %s", this, gpr_log(GPR_INFO, "[xds_client %p] creating channel to %s", this,
bootstrap_->server().server_uri.c_str()); bootstrap_->server().server_uri.c_str());
} }
grpc_channel_args* new_args = BuildXdsChannelArgs(channel_args);
grpc_channel* channel = CreateXdsChannel(*bootstrap_, *new_args, error);
grpc_channel_args_destroy(new_args);
if (*error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "[xds_client %p] failed to create xds channel: %s", this,
grpc_error_string(*error));
return;
}
chand_ = MakeOrphanable<ChannelState>( chand_ = MakeOrphanable<ChannelState>(
Ref(DEBUG_LOCATION, "XdsClient+ChannelState"), channel_args); Ref(DEBUG_LOCATION, "XdsClient+ChannelState"), channel);
if (service_config_watcher_ != nullptr) { if (service_config_watcher_ != nullptr) {
chand_->Subscribe(kLdsTypeUrl, std::string(server_name)); chand_->Subscribe(kLdsTypeUrl, std::string(server_name));
} }

@ -134,8 +134,7 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
class AdsCallState; class AdsCallState;
class LrsCallState; class LrsCallState;
ChannelState(RefCountedPtr<XdsClient> xds_client, ChannelState(RefCountedPtr<XdsClient> xds_client, grpc_channel* channel);
const grpc_channel_args& args);
~ChannelState(); ~ChannelState();
void Orphan() override; void Orphan() override;

Loading…
Cancel
Save