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

Check if another resource exists when creating an alias #13070

Merged
merged 4 commits into from
Jul 29, 2019

Conversation

jsoriano
Copy link
Member

When creating an alias, if an index exists with the same name, alias is
not created assuming that it already exists. This can create some
confusion in some cases, as users can see that setup works, but indexes
and aliases are not correctly configured afterwards, leading to field
mapping issues and other kinds of problems.

This change makes beats explictly check if the resource that already
exists is actually an alias, if not, it returns a different failure that
can be seen by the user when running setup.

When creating an alias, if an index exists with the same name, alias is
not created assuming that it already exists. This can create some
confusion in some cases, as users can see that setup works, but indexes
and aliases are not correctly configured afterwards, leading to field
mapping issues and other kinds of problems.

This change makes beats explictly check if the resource that already
exists is actually an alias, if not, it returns a different failure that
can be seen by the user when running setup.
@jsoriano jsoriano requested a review from a team as a code owner July 25, 2019 11:15
@jsoriano jsoriano self-assigned this Jul 25, 2019
Copy link

@urso urso left a comment

Choose a reason for hiding this comment

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

I'm ok with double-checking here, but it would be nice if HasAlias would already report an error if the resource found is no alias.

Maybe we should better use the cat API: https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-alias.html

@jsoriano
Copy link
Member Author

@urso I have added a check also to HasAlias. I am keeping the check also in CreateAlias because it shouldn't succeed if it is not able to create the alias. Let me know what you think.

Regarding using the cat API, I think it is better not to use it. For example it responses with status 200 (and an empty response) when a requested resource doesn't exist, this kind of things would force us to parse the responses.

@jsoriano
Copy link
Member Author

jenkins, test this again please

@jsoriano jsoriano requested a review from urso July 25, 2019 18:34
@jsoriano
Copy link
Member Author

jenkins, test this again please

@jsoriano
Copy link
Member Author

Failing tests are not related, merging this.

@jsoriano jsoriano merged commit 281aab1 into elastic:master Jul 29, 2019
@jsoriano jsoriano deleted the ilm-check-invalid-alias branch July 29, 2019 10:52
@andresrc andresrc added the v7.4.0 label Aug 7, 2019
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.

4 participants