-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fixing the deprecation warning for system indices to be logged once #1537
Conversation
Signed-off-by: Vacha <[email protected]>
Can one of the admins verify this patch? |
✅ Gradle Wrapper Validation success 4ca51a0 |
✅ Gradle Precommit success 4ca51a0 |
Signed-off-by: Vacha <[email protected]>
✅ Gradle Wrapper Validation success 35cec89 |
✅ Gradle Precommit success 35cec89 |
@@ -83,6 +83,8 @@ | |||
public static final String SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY = "_system_index_access_allowed"; | |||
public static final Version SYSTEM_INDEX_ENFORCEMENT_VERSION = LegacyESVersion.V_7_10_0; | |||
|
|||
private boolean isDeprecationWarningAlreadyLogged; |
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.
Does this need a default value?
@@ -364,13 +366,14 @@ private void checkSystemIndexAccess(Context context, Metadata metadata, Set<Inde | |||
.map(i -> i.getIndex().getName()) | |||
.sorted() // reliable order for testing | |||
.collect(Collectors.toList()); | |||
if (resolvedSystemIndices.isEmpty() == false) { | |||
if (resolvedSystemIndices.isEmpty() == false && !isDeprecationWarningAlreadyLogged) { |
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 has a potential race condition where two threads may end up logging and then flipping the value, no?
Can we solve this generically in some way where the deprecation logger can be configured to log only once from a given source? Might need to track those messages. |
I tried the tracking messages in the IndexNameExpressionResolver since it prints the deprecation warning for different indices, but didn't go ahead with that I was concerned that the size of the collection where the messages are being tracked might grow a lot. As for handling it generically in deprecation logger, the deprecation logger is used at a lot of places in the code with different warnings to print. Some of the messages are quite similar (example). Maybe we can change the messages to make them more generic to making tracking easier and generic. WDYT? |
start gradle check |
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 we want these deprecation messages to get wrapped into a class that is self-aware in terms of whether it has already been logged or not, then only log once. Otherwise we either have to track every message that gets logged, or end up with endless if
and booleans all over the place where we log something.
Definitely agree. I will work on this. |
Raised a new PR for all deprecation messages as discussed above. Closing this in favor of #1660 |
✅ Gradle Wrapper Validation success 35cec89 |
✅ Gradle Precommit success 35cec89 |
Signed-off-by: Vacha [email protected]
Description
The deprecation warnings for system indices to be logged once instead of spamming the user with multiple logs.
Issues Resolved
Closes #1108
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.