-
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
Adding a deprecation info API check for fractional byte value settings #77074
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ | |
import org.elasticsearch.common.settings.Setting; | ||
import org.elasticsearch.common.settings.Setting.Property; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.unit.ByteSizeValue; | ||
import org.elasticsearch.common.ssl.SslConfigurationKeys; | ||
import org.elasticsearch.common.unit.ByteSizeValue; | ||
import org.elasticsearch.common.util.concurrent.EsExecutors; | ||
import org.elasticsearch.common.util.set.Sets; | ||
import org.elasticsearch.core.TimeValue; | ||
|
@@ -36,9 +36,9 @@ | |
import org.elasticsearch.script.ScriptService; | ||
import org.elasticsearch.threadpool.FixedExecutorBuilder; | ||
import org.elasticsearch.transport.RemoteClusterService; | ||
import org.elasticsearch.xpack.core.DataTier; | ||
import org.elasticsearch.transport.SniffConnectionStrategy; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.DataTier; | ||
import org.elasticsearch.xpack.core.XPackSettings; | ||
import org.elasticsearch.xpack.core.security.SecurityField; | ||
import org.elasticsearch.xpack.core.security.authc.RealmConfig; | ||
|
@@ -48,6 +48,7 @@ | |
|
||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Locale; | ||
|
@@ -671,6 +672,33 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f | |
); | ||
} | ||
|
||
static DeprecationIssue checkFractionalByteValueSettings(final Settings settings, | ||
final PluginsAndModules pluginsAndModules, | ||
final ClusterState clusterState, | ||
final XPackLicenseState licenseState) { | ||
Map<String, String> fractionalByteSettings = new HashMap<>(); | ||
for (String key : settings.keySet()) { | ||
try { | ||
settings.getAsBytesSize(key, ByteSizeValue.ZERO); | ||
String stringValue = settings.get(key); | ||
if (stringValue.contains(".")) { | ||
fractionalByteSettings.put(key, stringValue); | ||
} | ||
} catch (Exception ignoreThis) { | ||
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. Hmm, I'm not a huge fan of Exception based control flow. I know that settings are registered with ClusterSettings and IndexScopedSettings so that settings can be validated against the master set, but I don't know if we can filter on the setting's data type due to type erasure, and I'm not sure if those are comprehensive for every setting either. |
||
// We expect anything that is not a byte setting to throw an exception, but we don't care about those | ||
} | ||
} | ||
if (fractionalByteSettings.isEmpty()) { | ||
return null; | ||
} | ||
String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/logging.html#deprecation-logging"; | ||
String message = "support for fractional byte size values is deprecated and will be removed in a future release"; | ||
String details = "change the following settings to non-fractional values: [" + | ||
fractionalByteSettings.entrySet().stream().map(fractionalByteSetting -> fractionalByteSetting.getKey() + "->" + | ||
fractionalByteSetting.getValue()).collect(Collectors.joining(", ")) + "]"; | ||
return new DeprecationIssue(DeprecationIssue.Level.WARNING, message, url, details, false, null); | ||
} | ||
|
||
static DeprecationIssue checkFrozenCacheLeniency(final Settings settings, | ||
final PluginsAndModules pluginsAndModules, | ||
final ClusterState clusterState, | ||
|
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 looks like it triggers deprecation logging as well for each fractional value read, do we want that?