grpclb: add description to lb sends no backends status (#6751)

This commit is contained in:
Jihun Cho 2020-02-25 11:05:36 -08:00 committed by GitHub
parent 47c0b0b792
commit 4b201267c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -91,6 +91,9 @@ final class GrpclbState {
@VisibleForTesting
static final PickResult DROP_PICK_RESULT =
PickResult.withDrop(Status.UNAVAILABLE.withDescription("Dropped as requested by balancer"));
@VisibleForTesting
static final Status NO_AVAILABLE_BACKENDS_STATUS =
Status.UNAVAILABLE.withDescription("LoadBalancer responded without any backends");
@VisibleForTesting
static final RoundRobinEntry BUFFER_ENTRY = new RoundRobinEntry() {
@ -742,7 +745,8 @@ final class GrpclbState {
if (backendList.isEmpty()) {
if (lbSentEmptyBackends) {
pickList =
Collections.<RoundRobinEntry>singletonList(new ErrorEntry(Status.UNAVAILABLE));
Collections.<RoundRobinEntry>singletonList(
new ErrorEntry(NO_AVAILABLE_BACKENDS_STATUS));
state = TRANSIENT_FAILURE;
} else {
pickList = Collections.singletonList(BUFFER_ENTRY);

View File

@ -1939,7 +1939,8 @@ public class GrpclbLoadBalancerTest {
inOrder.verify(helper).updateBalancingState(eq(TRANSIENT_FAILURE), pickerCaptor.capture());
RoundRobinPicker errorPicker = (RoundRobinPicker) pickerCaptor.getValue();
assertThat(errorPicker.pickList).containsExactly(new ErrorEntry(Status.UNAVAILABLE));
assertThat(errorPicker.pickList)
.containsExactly(new ErrorEntry(GrpclbState.NO_AVAILABLE_BACKENDS_STATUS));
lbResponseObserver.onNext(buildLbResponse(Collections.<ServerEntry>emptyList()));