Skip to content

Commit

Permalink
[DOCS] add comment to clarify cluster name resolution (#34014)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
javanna authored Sep 25, 2018
1 parent dfe5af0 commit 970407c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,10 @@ public Map<String, List<String>> groupClusterIndices(String[] requestIndices, Pr
List<String> clusters = clusterNameResolver.resolveClusterNames(remoteClusterNames, remoteClusterName);
if (clusters.isEmpty() == false) {
if (indexExists.test(index)) {
// we use : as a separator for remote clusters. might conflict if there is an index that is actually named
// remote_cluster_alias:index_name - for this case we fail the request. the user can easily change the cluster alias
// if that happens
//We use ":" as a separator for remote clusters. There may be a conflict if there is an index that is named
//remote_cluster_alias:index_name - for this case we fail the request. The user can easily change the cluster alias
//if that happens. Note that indices and aliases can be created with ":" in their names names up to 6.last, which
//means such names need to be supported until 7.last. It will be possible to remove this check from 8.0 on.
throw new IllegalArgumentException("Can not filter indices; index " + index +
" exists but there is also a remote cluster named: " + remoteClusterName);
}
Expand All @@ -242,6 +243,9 @@ public Map<String, List<String>> groupClusterIndices(String[] requestIndices, Pr
perClusterIndices.computeIfAbsent(clusterName, k -> new ArrayList<>()).add(indexName);
}
} else {
//Indices and aliases can be created with ":" in their names up to 6.last (although deprecated), and still be
//around in 7.x. That's why we need to be lenient here and treat the index as local although it contains ":".
//It will be possible to remove such leniency and assume that no local indices contain ":" only from 8.0 on.
perClusterIndices.computeIfAbsent(RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY, k -> new ArrayList<>()).add(index);
}
} else {
Expand Down

0 comments on commit 970407c

Please sign in to comment.