-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Fix _alias/<alias> returning non-matching data streams #104145
Conversation
Hi @mattc58, I've created a changelog YAML for you. |
The new REST test can be run with: It will fail with the current code with:
|
Pinging @elastic/es-data-management (Team:Data Management) |
Hi @mattc58, I've updated the changelog YAML for you. |
…o fix-96589-alias-datastreams
} | ||
|
||
{ | ||
GetAliasesRequest request = new GetAliasesRequest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a test in here that covers the exclusions case (like testFindAliasWithExclusion
but for findDataStreamAliases? I don't know that we even claim to support it, but we get it virtually for free with what you've done.
.toList(); | ||
if (aliases.isEmpty() == false) { | ||
result.put(requestedDataStream, aliases); | ||
if (dsAliases.containsKey(requestedDataStream)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this check is redundant now, right? In Metadata, the setter only puts things in the map that's returned if they are the things you passed in as the second argument to findDataStreamAliases
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is, can you just return the result of findDataStreamAliases
from this method?
*/ | ||
public Map<String, List<DataStreamAlias>> findDataStreamAliases(final String[] aliases, final String[] dataStreams) { | ||
ImmutableOpenMap.Builder<String, List<DataStreamAlias>> mapBuilder = ImmutableOpenMap.builder(); | ||
Map<String, List<DataStreamAlias>> dataStreamAliases = dataStreamAliasesByDataStream(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if at some point we'll need to start computing this outside of this method if users have a lot of data stream aliases. But doing it once per request doesn't seem all that bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if doing the analysis and guidelines suggested in #104456 would help guide us here. Maybe we could store aliases differently in cluster state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Seems like a big improvement over what we had.
--- | ||
"Test get alias with non-matching data streams": | ||
- skip: | ||
version: " - 8.12.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently pointed at main (8.13.0) and the PR isn't labeled with 8.12.1. We'll need to make sure to remember backport it, or change this version if this doesn't get backported in time for 8.12.1
@elasticsearchmachine run elasticsearch-ci/part-2 |
💚 Backport successful
|
This fixes a bug where GET _alias/<alias> would return non-matching data streams
This fixes a bug where
GET _alias/<alias>
would return non-matching data streams. This happens when security is enabled and when the index pattern is changed to["*',"-*"]
and the data streams don't properly process that.Fixes #96589.