-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Make sure _tier field handles missing setting #71439
Conversation
When `_tier_preference` isn't set, getting it returns an empty string "". This PR updates the _tier metadata field to detect this case correctly.
Pinging @elastic/es-search (Team:Search) |
@@ -53,7 +53,7 @@ protected boolean matches(String pattern, boolean caseInsensitive, SearchExecuti | |||
pattern = Strings.toLowercaseAscii(pattern); | |||
} | |||
String tierPreference = DataTierAllocationDecider.INDEX_ROUTING_PREFER_SETTING.get(context.getIndexSettings().getSettings()); | |||
if (tierPreference == null) { | |||
if (Strings.hasText(tierPreference) == false) { |
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 check is a little unusual, but it matches how we test for the setting in other places like DataTierAllocationDecider
.
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, I left a minor suggestion around reusing the existing test helper but leave it to you if you want to change that or not.
@@ -102,4 +117,18 @@ private SearchExecutionContext createContext() { | |||
emptyMap() | |||
); | |||
} | |||
|
|||
private SearchExecutionContext createContextWithoutSetting() { |
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.
nit: maybe we could re-use the other createContext() method by adding an argument (e.g. a bool flag) to either return a context with- or without the setting?
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.
Thanks for the suggestion, I'll stick with this approach as I find it clearest right now. We can always refactor if these methods grow larger and there's more duplication!
When `_tier_preference` isn't set, getting it returns an empty string "". This PR updates the _tier metadata field to detect this case correctly.
When
_tier_preference
isn't set, getting it returns an empty string "". ThisPR updates the _tier metadata field to detect this case correctly.
Relates to #68135.