-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Exposing the ability to log deprecated settings at non-critical level #79107
Merged
masseyke
merged 15 commits into
elastic:master
from
masseyke:feature/deprecated-settings-at-warning-level-master
Oct 19, 2021
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b1dfda3
Exposing the ability to log deprecated settings at non-critical level
masseyke 19788f4
replacing a previously existing method
masseyke d5884c6
fixing tests
masseyke b7b5f75
Merge branch 'master' into feature/deprecated-settings-at-warning-lev…
elasticmachine e25078d
code review feedback incorporated
masseyke 0dd2666
Merge branch 'feature/deprecated-settings-at-warning-level-master' of…
masseyke 4ac690d
code review feedback incorporated
masseyke d8c8dde
incorporating code review feedback
masseyke c90725b
Merge branch 'master' into feature/deprecated-settings-at-warning-lev…
masseyke bebb895
getting rid of compiler warning
masseyke 841fbb2
fixing a checkstyle problem
masseyke d2a82a7
fixing a checkstyle problem
masseyke 0c18846
Checking log level for all deprecation warnings
masseyke 9fa7f60
fixing compilation errors / cleaning up
masseyke 0bb8894
fixing a unit test
masseyke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,10 +99,15 @@ public enum Property { | |
Final, | ||
|
||
/** | ||
* mark this setting as deprecated | ||
* mark this setting as deprecated (critical level) | ||
*/ | ||
Deprecated, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice, as a followup (since it will touch so many files), to rename this. |
||
|
||
/** | ||
* mark this setting as deprecated (warning level) | ||
*/ | ||
DeprecatedWarning, | ||
|
||
/** | ||
* Node scope | ||
*/ | ||
|
@@ -169,6 +174,9 @@ private Setting(Key key, @Nullable Setting<T> fallbackSetting, Function<Settings | |
if (propertiesAsSet.contains(Property.Dynamic) && propertiesAsSet.contains(Property.OperatorDynamic)) { | ||
throw new IllegalArgumentException("setting [" + key + "] cannot be both dynamic and operator dynamic"); | ||
} | ||
if (propertiesAsSet.contains(Property.Deprecated) && propertiesAsSet.contains(Property.DeprecatedWarning)) { | ||
throw new IllegalArgumentException("setting [" + key + "] cannot be deprecated at both critical and warning levels"); | ||
} | ||
checkPropertyRequiresIndexScope(propertiesAsSet, Property.NotCopyableOnResize); | ||
checkPropertyRequiresIndexScope(propertiesAsSet, Property.InternalIndex); | ||
checkPropertyRequiresIndexScope(propertiesAsSet, Property.PrivateIndex); | ||
|
@@ -370,8 +378,12 @@ public boolean hasIndexScope() { | |
/** | ||
* Returns <code>true</code> if this setting is deprecated, otherwise <code>false</code> | ||
*/ | ||
public boolean isDeprecated() { | ||
return properties.contains(Property.Deprecated); | ||
private boolean isDeprecated() { | ||
return properties.contains(Property.Deprecated) || properties.contains(Property.DeprecatedWarning); | ||
} | ||
|
||
private boolean isDeprecatedWarningOnly() { | ||
return properties.contains(Property.DeprecatedWarning); | ||
} | ||
|
||
/** | ||
|
@@ -538,6 +550,8 @@ String innerGetRaw(final Settings settings) { | |
if (secureSettings != null && secureSettings.getSettingNames().contains(key)) { | ||
throw new IllegalArgumentException("Setting [" + key + "] is a non-secure setting" + | ||
" and must be stored inside elasticsearch.yml, but was found inside the Elasticsearch keystore"); | ||
|
||
|
||
} | ||
final String found = settings.get(key); | ||
if (found != null) { | ||
|
@@ -552,13 +566,15 @@ void checkDeprecation(Settings settings) { | |
if (this.isDeprecated() && this.exists(settings)) { | ||
// It would be convenient to show its replacement key, but replacement is often not so simple | ||
final String key = getKey(); | ||
|
||
List<String> skipTheseDeprecations = settings.getAsList("deprecation.skip_deprecated_settings"); | ||
if (Regex.simpleMatch(skipTheseDeprecations, key) == false) { | ||
Settings.DeprecationLoggerHolder.deprecationLogger | ||
.critical(DeprecationCategory.SETTINGS, key, | ||
"[{}] setting was deprecated in Elasticsearch and will be removed in a future release! " | ||
+ "See the breaking changes documentation for the next major version.", key); | ||
String message = "[{}] setting was deprecated in Elasticsearch and will be removed in a future release! " | ||
+ "See the breaking changes documentation for the next major version."; | ||
if (this.isDeprecatedWarningOnly()) { | ||
Settings.DeprecationLoggerHolder.deprecationLogger.warn(DeprecationCategory.SETTINGS, key, message, key); | ||
} else { | ||
Settings.DeprecationLoggerHolder.deprecationLogger.critical(DeprecationCategory.SETTINGS, key, message, key); | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Rather than adding another public method, can you please update the existing uses? It looks like there are ~12 calls to the existing method, and most are in tests, it should be easy to update with eg IntelliJ refactoring tools to add a parameter.
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.
Yeah I went back and forth on this. I actually did this and backed it out in an attempt to make this PR smaller. I'll consolidate it into one method.