|
|
@ -400,26 +400,24 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx, |
|
|
|
GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING); |
|
|
|
GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING); |
|
|
|
lb_policy_name = channel_arg->value.string; |
|
|
|
lb_policy_name = channel_arg->value.string; |
|
|
|
} |
|
|
|
} |
|
|
|
// Special case: If all of the addresses are balancer addresses,
|
|
|
|
// Special case: If at least one balancer address is present, we use
|
|
|
|
// assume that we should use the grpclb policy, regardless of what the
|
|
|
|
// the grpclb policy, regardless of what the resolver actually specified.
|
|
|
|
// resolver actually specified.
|
|
|
|
|
|
|
|
channel_arg = |
|
|
|
channel_arg = |
|
|
|
grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES); |
|
|
|
grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES); |
|
|
|
if (channel_arg != NULL && channel_arg->type == GRPC_ARG_POINTER) { |
|
|
|
if (channel_arg != NULL && channel_arg->type == GRPC_ARG_POINTER) { |
|
|
|
grpc_lb_addresses *addresses = channel_arg->value.pointer.p; |
|
|
|
grpc_lb_addresses *addresses = channel_arg->value.pointer.p; |
|
|
|
bool found_backend_address = false; |
|
|
|
bool found_balancer_address = false; |
|
|
|
for (size_t i = 0; i < addresses->num_addresses; ++i) { |
|
|
|
for (size_t i = 0; i < addresses->num_addresses; ++i) { |
|
|
|
if (!addresses->addresses[i].is_balancer) { |
|
|
|
if (addresses->addresses[i].is_balancer) { |
|
|
|
found_backend_address = true; |
|
|
|
found_balancer_address = true; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!found_backend_address) { |
|
|
|
if (found_balancer_address) { |
|
|
|
if (lb_policy_name != NULL && strcmp(lb_policy_name, "grpclb") != 0) { |
|
|
|
if (lb_policy_name != NULL && strcmp(lb_policy_name, "grpclb") != 0) { |
|
|
|
gpr_log(GPR_INFO, |
|
|
|
gpr_log(GPR_INFO, |
|
|
|
"resolver requested LB policy %s but provided only balancer " |
|
|
|
"resolver requested LB policy %s but provided at least one " |
|
|
|
"addresses, no backend addresses -- forcing use of grpclb LB " |
|
|
|
"balancer address -- forcing use of grpclb LB policy", |
|
|
|
"policy", |
|
|
|
|
|
|
|
lb_policy_name); |
|
|
|
lb_policy_name); |
|
|
|
} |
|
|
|
} |
|
|
|
lb_policy_name = "grpclb"; |
|
|
|
lb_policy_name = "grpclb"; |
|
|
|