Remove XdsClient from channel args to fix subchannel sharing.

pull/23073/head
Mark D. Roth 5 years ago
parent ec8ec630ac
commit 0a286b57ce
  1. 14
      src/core/ext/filters/client_channel/lb_policy/xds/eds.cc
  2. 6
      src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc
  3. 6
      src/core/ext/filters/client_channel/xds/xds_client.cc
  4. 2
      src/core/ext/filters/client_channel/xds/xds_client.h

@ -32,6 +32,7 @@
#include "src/core/ext/filters/client_channel/lb_policy_factory.h" #include "src/core/ext/filters/client_channel/lb_policy_factory.h"
#include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/server_address.h"
#include "src/core/ext/filters/client_channel/xds/xds_channel_args.h"
#include "src/core/ext/filters/client_channel/xds/xds_client.h" #include "src/core/ext/filters/client_channel/xds/xds_client.h"
#include "src/core/ext/filters/client_channel/xds/xds_client_stats.h" #include "src/core/ext/filters/client_channel/xds/xds_client_stats.h"
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
@ -715,11 +716,18 @@ grpc_channel_args* EdsLb::CreateChildPolicyArgsLocked(
grpc_channel_arg_integer_create( grpc_channel_arg_integer_create(
const_cast<char*>(GRPC_ARG_INHIBIT_HEALTH_CHECKING), 1), const_cast<char*>(GRPC_ARG_INHIBIT_HEALTH_CHECKING), 1),
}; };
absl::InlinedVector<const char*, 1> args_to_remove;
if (xds_client_from_channel_ == nullptr) { if (xds_client_from_channel_ == nullptr) {
args_to_add.emplace_back(xds_client_->MakeChannelArg()); args_to_add.emplace_back(xds_client_->MakeChannelArg());
} } else if (!config_->lrs_load_reporting_server_name().has_value()) {
return grpc_channel_args_copy_and_add(args, args_to_add.data(), // Remove XdsClient from channel args, so that its presence doesn't
args_to_add.size()); // prevent us from sharing subchannels between channels.
// If load reporting is enabled, this happens in the LRS policy instead.
args_to_remove.push_back(GRPC_ARG_XDS_CLIENT);
}
return grpc_channel_args_copy_and_add_and_remove(
args, args_to_remove.data(), args_to_remove.size(), args_to_add.data(),
args_to_add.size());
} }
OrphanablePtr<LoadBalancingPolicy> EdsLb::CreateChildPolicyLocked( OrphanablePtr<LoadBalancingPolicy> EdsLb::CreateChildPolicyLocked(

@ -254,9 +254,11 @@ void LrsLb::UpdateLocked(UpdateArgs args) {
config_->eds_service_name(), config_->locality_name()); config_->eds_service_name(), config_->locality_name());
MaybeUpdatePickerLocked(); MaybeUpdatePickerLocked();
} }
// Remove XdsClient from channel args, so that its presence doesn't
// prevent us from sharing subchannels between channels.
grpc_channel_args* new_args = XdsClient::RemoveFromChannelArgs(*args.args);
// Update child policy. // Update child policy.
UpdateChildPolicyLocked(std::move(args.addresses), args.args); UpdateChildPolicyLocked(std::move(args.addresses), new_args);
args.args = nullptr; // Ownership passed to UpdateChildPolicyLocked().
} }
void LrsLb::MaybeUpdatePickerLocked() { void LrsLb::MaybeUpdatePickerLocked() {

@ -2387,4 +2387,10 @@ RefCountedPtr<XdsClient> XdsClient::GetFromChannelArgs(
return nullptr; return nullptr;
} }
grpc_channel_args* XdsClient::RemoveFromChannelArgs(
const grpc_channel_args& args) {
const char* arg_name = GRPC_ARG_XDS_CLIENT;
return grpc_channel_args_copy_and_remove(&args, &arg_name, 1);
}
} // namespace grpc_core } // namespace grpc_core

@ -142,6 +142,8 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
grpc_arg MakeChannelArg() const; grpc_arg MakeChannelArg() const;
static RefCountedPtr<XdsClient> GetFromChannelArgs( static RefCountedPtr<XdsClient> GetFromChannelArgs(
const grpc_channel_args& args); const grpc_channel_args& args);
static grpc_channel_args* RemoveFromChannelArgs(
const grpc_channel_args& args);
private: private:
// Contains a channel to the xds server and all the data related to the // Contains a channel to the xds server and all the data related to the

Loading…
Cancel
Save