Skip to content

Commit

Permalink
Fix inconsistent cluster state and ensure weigh away exception check …
Browse files Browse the repository at this point in the history
…is done only on data nodes

Signed-off-by: Anshu Agarwal <[email protected]>
  • Loading branch information
Anshu Agarwal committed Feb 15, 2023
1 parent 6b35c32 commit f969d44
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,16 @@ private void executeHealth(
if (validationPredicate.test(currentState)) {
ClusterHealthResponse clusterHealthResponse = getResponse(request, currentState, waitCount, TimeoutState.OK);
if (request.ensureNodeWeighedIn() && clusterHealthResponse.hasDiscoveredClusterManager()) {
DiscoveryNode localNode = clusterService.state().getNodes().getLocalNode();
assert request.local() == true : "local node request false for request for local node weighed in";
boolean weighedAway = WeightedRoutingUtils.isWeighedAway(localNode.getId(), clusterService.state());
if (weighedAway) {
listener.onFailure(new NodeWeighedAwayException("local node is weighed away"));
return;
DiscoveryNode localNode = currentState.getNodes().getLocalNode();
if (localNode.isDataNode()) {
assert request.local() == true : "local node request false for request for local node weighed in";
boolean weighedAway = WeightedRoutingUtils.isWeighedAway(localNode.getId(), currentState);
if (weighedAway) {
listener.onFailure(new NodeWeighedAwayException("local node is weighed away"));
return;
}
}
}

listener.onResponse(clusterHealthResponse);
} else {
final ClusterStateObserver observer = new ClusterStateObserver(
Expand Down

0 comments on commit f969d44

Please sign in to comment.