Simplify the code in CreateRoundRobinPolicyArgsLocked() to always expect

serverlist_ to be present.
pull/17125/head
Vishal Powar 6 years ago
parent 970552f1ac
commit 0f24148733
  1. 26
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc

@ -1321,13 +1321,10 @@ void XdsLb::ProcessChannelArgsLocked(const grpc_channel_args& args) {
void XdsLb::UpdateLocked(const grpc_channel_args& args) { void XdsLb::UpdateLocked(const grpc_channel_args& args) {
ProcessChannelArgsLocked(args); ProcessChannelArgsLocked(args);
// If fallback is configured and the RR policy already exists, update // Note: We have disable fallback mode in the code, so we dont need to update
// it with the new fallback addresses. // the policy.
// Note: We have disable fallback mode in the code, so this will only happen // TODO(vpowar): Handle the fallback_address changes when we add support for
// when rr_policy_ is set because we have balancer received serverlist. // fallback in xDS.
if (lb_fallback_timeout_ms_ > 0 && rr_policy_ != nullptr) {
CreateOrUpdateRoundRobinPolicyLocked();
}
// Start watching the LB channel connectivity for connection, if not // Start watching the LB channel connectivity for connection, if not
// already doing so. // already doing so.
if (!watching_lb_channel_) { if (!watching_lb_channel_) {
@ -1642,15 +1639,12 @@ void XdsLb::CreateRoundRobinPolicyLocked(const Args& args) {
grpc_channel_args* XdsLb::CreateRoundRobinPolicyArgsLocked() { grpc_channel_args* XdsLb::CreateRoundRobinPolicyArgsLocked() {
grpc_lb_addresses* addresses; grpc_lb_addresses* addresses;
bool is_backend_from_grpclb_load_balancer = false; bool is_backend_from_grpclb_load_balancer = false;
if (serverlist_ != nullptr) { // This should never be invoked if we do not have serverlist_, as fallback
GPR_ASSERT(serverlist_->num_servers > 0); // mode is disabled for xDS plugin.
addresses = ProcessServerlist(serverlist_); GPR_ASSERT(serverlist_ != nullptr);
is_backend_from_grpclb_load_balancer = true; GPR_ASSERT(serverlist_->num_servers > 0);
} else { addresses = ProcessServerlist(serverlist_);
// This should never be invoked if we do not have serverlist_, as fallback is_backend_from_grpclb_load_balancer = true;
// mode is disabled for xDS plugin.
return nullptr;
}
GPR_ASSERT(addresses != nullptr); GPR_ASSERT(addresses != nullptr);
// Replace the LB addresses in the channel args that we pass down to // Replace the LB addresses in the channel args that we pass down to
// the subchannel. // the subchannel.

Loading…
Cancel
Save