Stop setting PROXYLESS_CLIENT_HOSTNAME node metadata in LRS request.

pull/24136/head
Mark D. Roth 4 years ago
parent f31a322e1c
commit 5107e65a93
  1. 4
      src/core/ext/filters/client_channel/lb_policy/xds/eds.cc
  2. 3
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  3. 17
      src/core/ext/xds/xds_api.cc
  4. 4
      src/core/ext/xds/xds_api.h
  5. 7
      src/core/ext/xds/xds_client.cc
  6. 9
      src/core/ext/xds/xds_client.h
  7. 5
      test/cpp/end2end/xds_end2end_test.cc

@ -460,8 +460,8 @@ void EdsLb::UpdateLocked(UpdateArgs args) {
// Initialize XdsClient.
if (xds_client_from_channel_ == nullptr) {
grpc_error* error = GRPC_ERROR_NONE;
xds_client_ = MakeOrphanable<XdsClient>(
work_serializer(), GetEdsResourceName(), *args_, &error);
xds_client_ =
MakeOrphanable<XdsClient>(work_serializer(), *args_, &error);
// TODO(roth): If we decide that we care about EDS-only mode, add
// proper error handling here.
GPR_ASSERT(error == GRPC_ERROR_NONE);

@ -467,8 +467,7 @@ ConfigSelector::CallConfig XdsResolver::XdsConfigSelector::GetCallConfig(
void XdsResolver::StartLocked() {
grpc_error* error = GRPC_ERROR_NONE;
xds_client_ = MakeOrphanable<XdsClient>(work_serializer(), server_name_,
*args_, &error);
xds_client_ = MakeOrphanable<XdsClient>(work_serializer(), *args_, &error);
if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR,
"Failed to create xds client -- channel will remain in "

@ -595,7 +595,6 @@ void PopulateBuildVersion(upb_arena* arena, envoy_config_core_v3_Node* node_msg,
void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
const std::string& build_version,
const std::string& user_agent_name,
const std::string& server_name,
envoy_config_core_v3_Node* node_msg) {
const XdsBootstrap::Node* node = bootstrap->node();
if (node != nullptr) {
@ -612,16 +611,6 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
envoy_config_core_v3_Node_mutable_metadata(node_msg, arena);
PopulateMetadata(arena, metadata, node->metadata.object_value());
}
if (!server_name.empty()) {
google_protobuf_Struct* metadata =
envoy_config_core_v3_Node_mutable_metadata(node_msg, arena);
google_protobuf_Value* value = google_protobuf_Value_new(arena);
google_protobuf_Value_set_string_value(value,
StdStringToUpbString(server_name));
google_protobuf_Struct_fields_set(
metadata, upb_strview_makez("PROXYLESS_CLIENT_HOSTNAME"), value,
arena);
}
if (!node->locality_region.empty() || !node->locality_zone.empty() ||
!node->locality_subzone.empty()) {
envoy_config_core_v3_Locality* locality =
@ -902,7 +891,7 @@ grpc_slice XdsApi::CreateAdsRequest(
envoy_config_core_v3_Node* node_msg =
envoy_service_discovery_v3_DiscoveryRequest_mutable_node(request,
arena.ptr());
PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_, "",
PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_,
node_msg);
}
// Add resource_names.
@ -2251,7 +2240,7 @@ grpc_slice SerializeLrsRequest(
} // namespace
grpc_slice XdsApi::CreateLrsInitialRequest(const std::string& server_name) {
grpc_slice XdsApi::CreateLrsInitialRequest() {
upb::Arena arena;
// Create a request.
envoy_service_load_stats_v3_LoadStatsRequest* request =
@ -2261,7 +2250,7 @@ grpc_slice XdsApi::CreateLrsInitialRequest(const std::string& server_name) {
envoy_service_load_stats_v3_LoadStatsRequest_mutable_node(request,
arena.ptr());
PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_,
server_name, node_msg);
node_msg);
envoy_config_core_v3_Node_add_client_features(
node_msg, upb_strview_makez("envoy.lrs.supports_send_all_clusters"),
arena.ptr());

@ -313,8 +313,8 @@ class XdsApi {
const std::set<absl::string_view>& expected_cluster_names,
const std::set<absl::string_view>& expected_eds_service_names);
// Creates an LRS request querying \a server_name.
grpc_slice CreateLrsInitialRequest(const std::string& server_name);
// Creates an initial LRS request.
grpc_slice CreateLrsInitialRequest();
// Creates an LRS request sending a client-side load report.
grpc_slice CreateLrsRequest(ClusterLoadReportMap cluster_load_report_map);

@ -1431,7 +1431,6 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
// activity in xds_client()->interested_parties_, which is comprised of
// the polling entities from client_channel.
GPR_ASSERT(xds_client() != nullptr);
GPR_ASSERT(!xds_client()->server_name_.empty());
const auto& method =
xds_client()->bootstrap_->server().ShouldUseV3()
? GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V3_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS
@ -1443,7 +1442,7 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
GPR_ASSERT(call_ != nullptr);
// Init the request payload.
grpc_slice request_payload_slice =
xds_client()->api_.CreateLrsInitialRequest(xds_client()->server_name_);
xds_client()->api_.CreateLrsInitialRequest();
send_message_payload_ =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_slice_unref_internal(request_payload_slice);
@ -1767,7 +1766,6 @@ grpc_channel* CreateXdsChannel(const XdsBootstrap& bootstrap,
} // namespace
XdsClient::XdsClient(std::shared_ptr<WorkSerializer> work_serializer,
absl::string_view server_name,
const grpc_channel_args& channel_args, grpc_error** error)
: InternallyRefCounted<XdsClient>(&grpc_xds_client_trace),
request_timeout_(GetRequestTimeout(channel_args)),
@ -1775,8 +1773,7 @@ XdsClient::XdsClient(std::shared_ptr<WorkSerializer> work_serializer,
interested_parties_(grpc_pollset_set_create()),
bootstrap_(
XdsBootstrap::ReadFromFile(this, &grpc_xds_client_trace, error)),
api_(this, &grpc_xds_client_trace, bootstrap_.get()),
server_name_(server_name) {
api_(this, &grpc_xds_client_trace, bootstrap_.get()) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, "[xds_client %p] creating xds client", this);
}

@ -91,10 +91,7 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
// If *error is not GRPC_ERROR_NONE after construction, then there was
// an error initializing the client.
// TODO(roth): Remove the server_name parameter as part of sharing the
// XdsClient instance between channels.
XdsClient(std::shared_ptr<WorkSerializer> work_serializer,
absl::string_view server_name,
const grpc_channel_args& channel_args, grpc_error** error);
~XdsClient();
@ -309,12 +306,6 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
std::unique_ptr<XdsBootstrap> bootstrap_;
XdsApi api_;
// TODO(roth): In order to share the XdsClient instance between
// channels and servers, we will need to remove this field. In order
// to do that, we'll need to figure out if we can stop sending the
// server name as part of the node metadata in the LRS request.
const std::string server_name_;
// The channel for communicating with the xds server.
OrphanablePtr<ChannelState> chand_;

@ -1196,11 +1196,6 @@ class LrsServiceImpl : public std::enable_shared_from_this<LrsServiceImpl> {
LoadStatsRequest request;
if (stream->Read(&request)) {
CountedService<typename RpcApi::Service>::IncreaseRequestCount();
// Verify server name set in metadata.
auto it = request.node().metadata().fields().find(
"PROXYLESS_CLIENT_HOSTNAME");
GPR_ASSERT(it != request.node().metadata().fields().end());
EXPECT_EQ(it->second.string_value(), kDefaultResourceName);
// Verify client features.
EXPECT_THAT(
request.node().client_features(),

Loading…
Cancel
Save