Skip to content

Commit

Permalink
Adding check for atleast one remote node to mark as migration ongoing
Browse files Browse the repository at this point in the history
Signed-off-by: Shourya Dutta Biswas <114977491+shourya035@users.noreply.github.com>
  • Loading branch information
shourya035 committed Jun 3, 2024
1 parent b470ddb commit ea8de1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableSet;
import static org.opensearch.index.remote.RemoteStoreUtils.hasAtleastOneRemoteNode;
import static org.opensearch.node.remotestore.RemoteStoreNodeService.isMigratingToRemoteStore;

/**
Expand Down Expand Up @@ -142,7 +143,7 @@ public RoutingAllocation(
this.clusterInfo = clusterInfo;
this.shardSizeInfo = shardSizeInfo;
this.currentNanoTime = currentNanoTime;
if (isMigratingToRemoteStore(metadata)) {
if (isMigratingToRemoteStore(metadata) && hasAtleastOneRemoteNode(nodes)) {
indexMetadataUpdater.setOngoingRemoteStoreMigration(true);
indexMetadataUpdater.setRepositoriesService(determineRepositoriesService(snapshotsInfoService));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,10 @@ public static Map<String, String> getRemoteStoreRepoName(DiscoveryNodes discover
.findFirst();
return remoteNode.map(RemoteStoreNodeAttribute::getDataRepoNames).orElseGet(HashMap::new);
}

public static boolean hasAtleastOneRemoteNode(DiscoveryNodes discoveryNodes) {
Map<String, DiscoveryNode> dataNodes = discoveryNodes.getDataNodes();
return dataNodes.isEmpty() == false
&& dataNodes.keySet().stream().anyMatch(nodeId -> discoveryNodes.get(nodeId).isRemoteStoreNode());
}
}

0 comments on commit ea8de1f

Please sign in to comment.