-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Enable deprecation checks for removed settings #53317
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
jasontedor
merged 6 commits into
elastic:master
from
jasontedor:removed-setting-deprecation-check
Mar 11, 2020
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e54110e
Enable deprecation checks for removed settings
jasontedor b29c683
Fix imports
jasontedor c366117
Fix forbidden call
jasontedor 42b5aad
Consistency
jasontedor efb7740
Merge branch 'master' into removed-setting-deprecation-check
elasticmachine e9a24da
Update x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpac…
jasontedor 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
30 changes: 30 additions & 0 deletions
30
.../deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.deprecation; | ||
|
||
import org.elasticsearch.common.settings.Setting; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; | ||
|
||
import java.util.Locale; | ||
|
||
public class NodeDeprecationChecks { | ||
|
||
static DeprecationIssue checkRemovedSetting(final Settings settings, final Setting<?> removedSetting, final String url) { | ||
if (removedSetting.exists(settings) == false) { | ||
return null; | ||
} | ||
final String removedSettingKey = removedSetting.getKey(); | ||
final String value = removedSetting.get(settings).toString(); | ||
final String message = | ||
String.format(Locale.ROOT, "setting [%s] is deprecated and will be removed in the next major version", removedSettingKey); | ||
final String details = | ||
String.format(Locale.ROOT, "the setting [%s] is currently set to [%s], remove this setting", removedSettingKey, value); | ||
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...ecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.deprecation; | ||
|
||
import org.elasticsearch.common.settings.Setting; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
public class NodeDeprecationChecksTests extends ESTestCase { | ||
|
||
public void testRemovedSettingNotSet() { | ||
final Settings settings = Settings.EMPTY; | ||
final Setting<?> removedSetting = Setting.simpleString("node.removed_setting"); | ||
final DeprecationIssue issue = | ||
NodeDeprecationChecks.checkRemovedSetting(settings, removedSetting, "http://removed-setting.example.com"); | ||
assertThat(issue, nullValue()); | ||
} | ||
|
||
public void testRemovedSetting() { | ||
final Settings settings = Settings.builder().put("node.removed_setting", "value").build(); | ||
final Setting<?> removedSetting = Setting.simpleString("node.removed_setting"); | ||
final DeprecationIssue issue = | ||
NodeDeprecationChecks.checkRemovedSetting(settings, removedSetting, "https://removed-setting.example.com"); | ||
assertThat(issue, not(nullValue())); | ||
assertThat(issue.getLevel(), equalTo(DeprecationIssue.Level.CRITICAL)); | ||
assertThat( | ||
issue.getMessage(), | ||
equalTo("setting [node.removed_setting] is deprecated and will be removed in the next major version")); | ||
assertThat( | ||
issue.getDetails(), | ||
equalTo("the setting [node.removed_setting] is currently set to [value], remove this setting")); | ||
assertThat(issue.getUrl(), equalTo("https://removed-setting.example.com")); | ||
} | ||
|
||
} |
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.
should this be
WARNING
instead ofCRITICAL
?If the setting is removed, won't it be be "archived" allowing the server to continue to function ? I think we are trying to reserve
CRITICAL
for things items that will prevent the server from running.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.
Not necessarily, because these could be node level settings, which we don't archive, which do prevent startup if they are unrecognized. Also, we have discussing removing the archiving of settings, so this behavior could change for cluster-level settings too.
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.
In that case, should we flex WARNING or CRITICAL based if the setting has node scope ?
Also, should we check that that value is not the default value here so we don't issue an issue a deprecation issue for settings that user never changed ?
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.
There is a check that the setting is not set on line 18?
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.
ah .. i missed "Note that fallback settings are excluded." in the exists method.
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, that's why we have
Setting#existsOrFallbackExists
.