Skip to content

Restrict template name when putting index template#53970

Closed
spinscale wants to merge 1 commit intoelastic:masterfrom
spinscale:2003-change-naming-of-index-template
Closed

Restrict template name when putting index template#53970
spinscale wants to merge 1 commit intoelastic:masterfrom
spinscale:2003-change-naming-of-index-template

Conversation

@spinscale
Copy link
Copy Markdown
Contributor

Storing an index template named * will result in the in ability to
delete it. Also that naming is really confusing.

Reviewers Note: I pretty much like the logic in MetaDataCreateIndexService.validateIndexOrAliasName that we could probably use for templates as well. I just added the smallest fix to prevent the above behaviour.

This change breaks BWC, but I still think it's worth getting in (in master), as this happens due to user mistakes. See https://discuss.elastic.co/t/template-with-asterisk-name/224452

Storing an index template named `*` will result in the in ability to
delete it. Also that naming is really confusing.
@cbuescher cbuescher added :Search Foundations/Mapping Index mappings, including merging and defining field types v8.0.0 labels Mar 24, 2020
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@cbuescher cbuescher self-assigned this Apr 3, 2020
Copy link
Copy Markdown
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

Hi @spinscale, I took a look and the asterisk behaviour looks really trappy indeed, especially for deletion.

I pretty much like the logic in MetaDataCreateIndexService.validateIndexOrAliasName

There seems to be naming conventions for template names already, (see MetadataIndexTemplateService#validate()), so I would probably look into adding an additional case there.

Unfortunately most of the rules checked there look pretty much undocumented, maybe you could also add a few lines to the docs in terms of documentation?

Another more general issue I'm curious about wrt to this PR: poking around I found that in the course of the work for "Index Templates v2" (#53101) we are adding other code paths to putting index templates. I wonder if validation of names is or will be also included there, currently it doesn't seem to be. Maybe @martijnvg or somebody else from @elastic/es-core-infra can comment on this aspect? Also they might have an opinion about the breaking nature of an additional restriction in naming rules.

@andreidan andreidan added :Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. and removed :Search Foundations/Mapping Index mappings, including merging and defining field types labels May 4, 2020
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Indices APIs)

@elasticmachine elasticmachine added the Team:Data Management (obsolete) DO NOT USE. This team no longer exists. label May 4, 2020
@cbuescher
Copy link
Copy Markdown
Member

@andreidan thanks for correcting the assigned team, I would mostly like to get an opinion on where to best put the proposed validation (dissallow asterisks) on template names. Currently most of the restrictions are checked in MetadataIndexTemplateService#validate(), we can add it there but I also want to check what's planned in terms of validation for template names for v2. Maybe reusing the current logic there makes sense, otherwise we can track that in a separate issue and move forward here?

@dakrone
Copy link
Copy Markdown
Member

dakrone commented May 4, 2020

Maybe reusing the current logic there makes sense, otherwise we can track that in a separate issue and move forward here?

Yes, re-using the logic would be best. I'll add this as a todo for the meta issue #53101

dakrone added a commit to dakrone/elasticsearch that referenced this pull request May 4, 2020
This commit changes the validation for V2 index and component templates to re-use the same
validation that V1 templates used. This includes things like invalid template names, index patterns,
etc.

This also adds validation that template names do not contain `*`.

Supercedes elastic#53970
Relates to elastic#53101
@dakrone
Copy link
Copy Markdown
Member

dakrone commented May 4, 2020

I opened #56170 to address this in a generic way for v1 and v2 templates.

@cbuescher
Copy link
Copy Markdown
Member

@spinscale with #56170 open which should adress your issue, I hope you don't mind if I close this.

@cbuescher cbuescher closed this May 5, 2020
dakrone added a commit that referenced this pull request May 5, 2020
This commit changes the validation for V2 index and component templates to re-use the same
validation that V1 templates used. This includes things like invalid template names, index patterns,
etc.

This also adds validation that template names do not contain `*` and index patterns do not contain 
`:` (index names can't contain this regardless).

Supercedes #53970
Relates to #53101
Resolves #43737
Resolves #46045
dakrone added a commit to dakrone/elasticsearch that referenced this pull request May 5, 2020
This commit changes the validation for V2 index and component templates to re-use the same
validation that V1 templates used. This includes things like invalid template names, index patterns,
etc.

This also adds validation that template names do not contain `*` and index patterns do not contain
`:` (index names can't contain this regardless).

Supercedes elastic#53970
Relates to elastic#53101
Resolves elastic#43737
Resolves elastic#46045
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. Team:Data Management (obsolete) DO NOT USE. This team no longer exists. v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants