Skip to content

Commit 726674c

Browse files
javannakcm
authored andcommitted
[DOCS] add comment to clarify cluster name resolution (#34014)
We currently fallback to local indices whenever a remote cluster is not found, as there may still be indices / aliases with the same name. Such behaviour is lenient but needs to be kept for backwards compatibility. Clarified that in the code so we don't forget. Relates to #26247
1 parent b055fd0 commit 726674c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,10 @@ public Map<String, List<String>> groupClusterIndices(String[] requestIndices, Pr
231231
List<String> clusters = clusterNameResolver.resolveClusterNames(remoteClusterNames, remoteClusterName);
232232
if (clusters.isEmpty() == false) {
233233
if (indexExists.test(index)) {
234-
// we use : as a separator for remote clusters. might conflict if there is an index that is actually named
235-
// remote_cluster_alias:index_name - for this case we fail the request. the user can easily change the cluster alias
236-
// if that happens
234+
//We use ":" as a separator for remote clusters. There may be a conflict if there is an index that is named
235+
//remote_cluster_alias:index_name - for this case we fail the request. The user can easily change the cluster alias
236+
//if that happens. Note that indices and aliases can be created with ":" in their names names up to 6.last, which
237+
//means such names need to be supported until 7.last. It will be possible to remove this check from 8.0 on.
237238
throw new IllegalArgumentException("Can not filter indices; index " + index +
238239
" exists but there is also a remote cluster named: " + remoteClusterName);
239240
}
@@ -242,6 +243,9 @@ public Map<String, List<String>> groupClusterIndices(String[] requestIndices, Pr
242243
perClusterIndices.computeIfAbsent(clusterName, k -> new ArrayList<>()).add(indexName);
243244
}
244245
} else {
246+
//Indices and aliases can be created with ":" in their names up to 6.last (although deprecated), and still be
247+
//around in 7.x. That's why we need to be lenient here and treat the index as local although it contains ":".
248+
//It will be possible to remove such leniency and assume that no local indices contain ":" only from 8.0 on.
245249
perClusterIndices.computeIfAbsent(RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY, k -> new ArrayList<>()).add(index);
246250
}
247251
} else {

0 commit comments

Comments
 (0)