Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation for data stream creation #54083

Merged
merged 9 commits into from
Mar 26, 2020

Conversation

danhermann
Copy link
Contributor

Prevent name conflicts with existing indices or aliases.

Relates to #53100

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Data streams)

@danhermann danhermann changed the title Data stream names validation Validation for data stream creation Mar 25, 2020
@danhermann danhermann marked this pull request as ready for review March 25, 2020 17:31
@danhermann
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

@danhermann
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@martijnvg
Copy link
Member

@elasticmachine run elasticsearch-ci/1

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Left a few minor comments to consider.

SortedMap<?, ?> map = aliasAndIndexLookup.subMap(ds.getName() + "-", ds.getName() + "."); // '.' is the char after '-'
if (map.size() != 0) {
throw new IllegalStateException("data stream [" + ds.getName() +
"] could create backing indices that conflict with existing indices or aliases");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include the list of conflicting names in the message or at least the first few?

@@ -165,9 +166,11 @@ static ClusterState createDataStream(ClusterState currentState, Request request)
throw new IllegalArgumentException("data_stream [" + request.name + "] already exists");
}

MetaDataCreateIndexService.validateIndexOrAliasName(request.name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename the method to either "validateIndexSpaceName" or "validateAbstractIndexName"? Can be done in a follow-up when the naming discussion is clarified.

@@ -165,9 +166,11 @@ static ClusterState createDataStream(ClusterState currentState, Request request)
throw new IllegalArgumentException("data_stream [" + request.name + "] already exists");
}

MetaDataCreateIndexService.validateIndexOrAliasName(request.name,
(s1, s2) -> new IllegalArgumentException("data_stream [" + s1 + "] " + s2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other usages of validateIndexOrAliasName throw a dedicated exception. I am not entirely sure if IllegalArgumentException results in the same RestStatus and message handling. Could we add this to the rest test suite?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a REST test to enforce that the same HTTP 400 response code is returned.

@danhermann
Copy link
Contributor Author

@elasticmachine update branch

@danhermann
Copy link
Contributor Author

@elasticmachine update branch

@danhermann danhermann merged commit db6aba4 into elastic:master Mar 26, 2020
@danhermann danhermann deleted the data_streams_validation branch March 26, 2020 23:23
danhermann added a commit to danhermann/elasticsearch that referenced this pull request Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants