Skip to content

Commit

Permalink
address nullaway failure
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhee17 committed Aug 5, 2024
1 parent 5c198f6 commit 885f7f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ HostsSource hostSourceToUse(DefaultLbState lbState, XdsRandom random,
if (priority != 0 ||
localityRoutingState == null ||
localityRoutingState.state() == State.NO_LOCALITY_ROUTING ||
prioritySet.routingEnabled() <= random.nextInt(100, ROUTING_ENABLED)) {
prioritySet.routingEnabled() <= random.nextInt(100, ROUTING_ENABLED) ||
localityRoutingState.localHostSet() == null) {
return new HostsSource(priority, sourceType(hostAvailability));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ LocalityRoutingState create(PrioritySet upstreamPrioritySet, PrioritySet localPr
// Only priority 0 is supported
final HostSet upstreamHostSet = upstreamPrioritySet.hostSets().get(0);
final HostSet localHostSet = localPrioritySet.hostSets().get(0);
if (earlyExitNonLocalityRouting(upstreamHostSet, localHostSet, localLocality,
if (upstreamHostSet == null || localHostSet == null ||
earlyExitNonLocalityRouting(upstreamHostSet, localHostSet, localLocality,
upstreamPrioritySet.minClusterSize())) {
return new LocalityRoutingState(State.NO_LOCALITY_ROUTING, localHostSet, localLocality);
}
Expand Down Expand Up @@ -121,10 +122,11 @@ static final class LocalityRoutingState {
private final State state;
private final long localPercentageToRoute;
private final List<ResidualCapacity> residualCapacities;
@Nullable
private final HostSet localHostSet;
private final Locality localLocality;

private LocalityRoutingState(State state, HostSet localHostSet, Locality localLocality) {
private LocalityRoutingState(State state, @Nullable HostSet localHostSet, Locality localLocality) {
assert state == State.NO_LOCALITY_ROUTING || state == State.LOCALITY_DIRECT;
this.state = state;
localPercentageToRoute = 0;
Expand All @@ -147,6 +149,7 @@ State state() {
return state;
}

@Nullable
HostSet localHostSet() {
return localHostSet;
}
Expand Down Expand Up @@ -238,12 +241,8 @@ private static Map<Locality, LocalityPercentages> calculateLocalityPercentages(
return localityPercentagesBuilder.build();
}

private static boolean earlyExitNonLocalityRouting(@Nullable HostSet upstreamHostSet,
@Nullable HostSet localHostSet,
private static boolean earlyExitNonLocalityRouting(HostSet upstreamHostSet, HostSet localHostSet,
Locality localLocality, long minClusterSize) {
if (upstreamHostSet == null || localHostSet == null) {
return true;
}
final Map<Locality, EndpointGroup> upstreamHealthyHostsPerLocality =
upstreamHostSet.healthyEndpointGroupPerLocality();
final Map<Locality, EndpointGroup> localHealthyHostsPerLocality =
Expand Down

0 comments on commit 885f7f8

Please sign in to comment.