Disallow : in cluster and index/alias names (#26247)

We use `:` for cross-cluster search (eg `cluster:index`), therefore, we should
not allow the ambiguity when allowing cluster or index names.

Relates to #23892
This commit is contained in:
Lee Hinman 2017-08-17 14:57:26 -06:00 committed by GitHub
parent 4e97be02a9
commit f18ec511ca
6 changed files with 29 additions and 0 deletions

View File

@ -34,6 +34,9 @@ public class ClusterName implements Writeable {
if (s.isEmpty()) {
throw new IllegalArgumentException("[cluster.name] must not be empty");
}
if (s.contains(":")) {
throw new IllegalArgumentException("[cluster.name] must not contain ':'");
}
return new ClusterName(s);
}, Setting.Property.NodeScope);

View File

@ -165,6 +165,9 @@ public class MetaDataCreateIndexService extends AbstractComponent {
if (index.contains("#")) {
throw exceptionCtor.apply(index, "must not contain '#'");
}
if (index.contains(":")) {
throw exceptionCtor.apply(index, "must not contain ':'");
}
if (index.charAt(0) == '_' || index.charAt(0) == '-' || index.charAt(0) == '+') {
throw exceptionCtor.apply(index, "must not start with '_', '-', or '+'");
}

View File

@ -212,6 +212,7 @@ public class MetaDataCreateIndexServiceTests extends ESTestCase {
validateIndexName("..", "must not be '.' or '..'");
validateIndexName("foo:bar", "must not contain ':'");
}
private void validateIndexName(String indexName, String errorMessage) {

View File

@ -21,3 +21,11 @@ way to reindex old indices is to use the `reindex` API.
=========================================
[float]
=== Also see:
* <<breaking_70_cluster_changes>>
* <<breaking_70_indices_changes>>
include::migrate_7_0/cluster.asciidoc[]
include::migrate_7_0/indices.asciidoc[]

View File

@ -0,0 +1,7 @@
[[breaking_70_cluster_changes]]
=== Cluster changes
==== `:` is no longer allowed in cluster name
Due to cross-cluster search using `:` to separate a cluster and index name,
cluster names may no longer contain `:`.

View File

@ -0,0 +1,7 @@
[[breaking_70_indices_changes]]
=== Indices changes
==== `:` is no longer allowed in index name
Due to cross-cluster search using `:` to separate a cluster and index name,
index names may no longer contain `:`.