Skip to content

[Failure Store] Fix resolved alias retrieval for failure indices #127458

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

Merged
merged 6 commits into from
Apr 29, 2025

Conversation

gmarouli
Copy link
Contributor

While expanding our tests in #126891, we discovered that there was a difference in behaviour when an alias was used during search.

Expected behaviour

When a user uses an alias to access data, we pass this alias also to the node requests because that ensures that the user's authorisation will be evaluated based on the same premise.

Observed behaviour

When a user would use the alias and the ::failures selector, we noticed that the request was resolved to the failure indices and the alias was not used further which sometimes resulted in an unauthorised error. The reason was that when a node different than the coordinating node would try to evaluate if the user has permissions, they would evaluate that against the failure indices themselves and not the alias with the ::failures selector.

Solution
In this PR we ensure that a resolved alias is retrieved for failure indices too.

The indexAliases method is used in two ways (in production code):

  1. To retrieve all the resolved aliases that match an index
  2. To retrieve the filtered aliases that match the index (when there is no unfiltered reference to this index)

Because failure indices are not supported by filtered aliases, the code would return null when a failure index was encountered. That works well for the second case and not for the first.

In order to address that we moved the check for the failure index to the data stream alias predicate and we let the code match failure indices against resolved failure expressions and backing indices against resolved data expressions.

Furthermore, we added methods capturing these two common cases so the users of these methods for not need to know the details of how to call them.

@gmarouli gmarouli added >non-issue :Data Management/Data streams Data streams and their lifecycles auto-backport Automatically create backport pull requests when merged v8.19.0 labels Apr 28, 2025
@elasticsearchmachine elasticsearchmachine added Team:Data Management Meta label for data/management team v9.1.0 labels Apr 28, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@gmarouli gmarouli requested review from slobodanadamovic and jbaiera and removed request for slobodanadamovic April 28, 2025 14:23
Copy link
Contributor

@slobodanadamovic slobodanadamovic left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Thank you for fixing this!

gmarouli and others added 2 commits April 29, 2025 09:21
@gmarouli gmarouli merged commit f209db6 into elastic:main Apr 29, 2025
16 of 17 checks passed
@gmarouli gmarouli deleted the fix-alias-retrieval-for-failures branch April 29, 2025 08:50
@elasticsearchmachine
Copy link
Collaborator

elasticsearchmachine commented Apr 29, 2025

💚 Backport succeeded

Status Branch Result
8.19

gmarouli added a commit to gmarouli/elasticsearch that referenced this pull request Apr 29, 2025
…stic#127458)

While expanding our tests in elastic#126891, we discovered that there was a difference in behaviour when an alias was used during search.

Expected behaviour

When a user uses an alias to access data, we pass this alias also to the node requests because that ensures that the user's authorisation will be evaluated based on the same premise.

Observed behaviour

When a user would use the alias and the ::failures selector, we noticed that the request was resolved to the failure indices and the alias was not used further which sometimes resulted in an unauthorised error. The reason was that when a node different than the coordinating node would try to evaluate if the user has permissions, they would evaluate that against the failure indices themselves and not the alias with the ::failures selector.

Solution
In this PR we ensure that a resolved alias is retrieved for failure indices too.

The indexAliases method is used in two ways (in production code):

To retrieve all the resolved aliases that match an index
To retrieve the filtered aliases that match the index (when there is no unfiltered reference to this index)
Because failure indices are not supported by filtered aliases, the code would return null when a failure index was encountered. That works well for the second case and not for the first.

In order to address that we moved the check for the failure index to the data stream alias predicate and we let the code match failure indices against resolved failure expressions and backing indices against resolved data expressions.

Furthermore, we added methods capturing these two common cases so the users of these methods for not need to know the details of how to call them.

(cherry picked from commit f209db6)
@gmarouli
Copy link
Contributor Author

Backport: #127498

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged backport pending :Data Management/Data streams Data streams and their lifecycles >non-issue Team:Data Management Meta label for data/management team v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants