Skip to content

Commit

Permalink
Reduce deprecation logging severity for settings that are not removed…
Browse files Browse the repository at this point in the history
… in 8.0 (#79665)

This commit lowers the severity for all settings from critical to warning
for all settings that are still present in 8.0.0.

releated #79107
  • Loading branch information
jakelandis committed Oct 27, 2021
1 parent f20a0dc commit 6e3a108
Show file tree
Hide file tree
Showing 38 changed files with 209 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class SslConfigurationKeys {
public static final String TRUSTSTORE_SECURE_PASSWORD = "truststore.secure_password";
/**
* The password for the file configured in {@link #TRUSTSTORE_PATH}, as a non-secure setting.
* The use of this setting {@link #isDeprecated(String) is deprecated}.
* The use of this setting {@link #isDeprecatedWarning(String) is deprecated}.
*/
public static final String TRUSTSTORE_LEGACY_PASSWORD = "truststore.password";
/**
Expand All @@ -82,7 +82,7 @@ public class SslConfigurationKeys {
public static final String KEYSTORE_SECURE_PASSWORD = "keystore.secure_password";
/**
* The password for the file configured in {@link #KEYSTORE_PATH}, as a non-secure setting.
* The use of this setting {@link #isDeprecated(String) is deprecated}.
* The use of this setting {@link #isDeprecatedWarning(String) is deprecated}.
*/
public static final String KEYSTORE_LEGACY_PASSWORD = "keystore.password";
/**
Expand All @@ -92,7 +92,7 @@ public class SslConfigurationKeys {
public static final String KEYSTORE_SECURE_KEY_PASSWORD = "keystore.secure_key_password";
/**
* The password for the key within the {@link #KEYSTORE_PATH configured keystore}, as a non-secure setting.
* The use of this setting {@link #isDeprecated(String) is deprecated}.
* The use of this setting {@link #isDeprecatedWarning(String) is deprecated}.
* If no key password is specified, it will default to the keystore password.
*/
public static final String KEYSTORE_LEGACY_KEY_PASSWORD = "keystore.key_password";
Expand Down Expand Up @@ -121,11 +121,14 @@ public class SslConfigurationKeys {
public static final String KEY_SECURE_PASSPHRASE = "secure_key_passphrase";
/**
* The password to read the configured {@link #KEY}, as a non-secure setting.
* The use of this setting {@link #isDeprecated(String) is deprecated}.
* The use of this setting {@link #isDeprecatedWarning(String) is deprecated}.
*/
public static final String KEY_LEGACY_PASSPHRASE = "key_passphrase";

private static final Set<String> DEPRECATED_KEYS = new HashSet<>(
/**
* Warning severity deprecated keys
*/
private static final Set<String> DEPRECATED_WARNING_KEYS = new HashSet<>(
Arrays.asList(TRUSTSTORE_LEGACY_PASSWORD, KEYSTORE_LEGACY_PASSWORD, KEYSTORE_LEGACY_KEY_PASSWORD, KEY_LEGACY_PASSPHRASE)
);

Expand Down Expand Up @@ -161,10 +164,10 @@ public static List<String> getSecureStringKeys() {
}

/**
* @return {@code true} if the provided key is a deprecated setting
* @return {@code true} if the provided key is a deprecated setting at warning severity
*/
public static boolean isDeprecated(String key) {
return DEPRECATED_KEYS.contains(key);
public static boolean isDeprecatedWarning(String key) {
return DEPRECATED_WARNING_KEYS.contains(key);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ public class ReindexSslConfig {

static {
Setting.Property[] defaultProperties = new Setting.Property[] { Setting.Property.NodeScope, Setting.Property.Filtered };
Setting.Property[] deprecatedProperties = new Setting.Property[] { Setting.Property.Deprecated, Setting.Property.NodeScope,
Setting.Property[] deprecatedProperties = new Setting.Property[] { Setting.Property.DeprecatedWarning, Setting.Property.NodeScope,
Setting.Property.Filtered };
for (String key : SslConfigurationKeys.getStringKeys()) {
String settingName = "reindex.ssl." + key;
final Setting.Property[] properties = SslConfigurationKeys.isDeprecated(key) ? deprecatedProperties : defaultProperties;
final Setting.Property[] properties = SslConfigurationKeys.isDeprecatedWarning(key) ? deprecatedProperties : defaultProperties;
SETTINGS.put(settingName, simpleString(settingName, properties));
}
for (String key : SslConfigurationKeys.getListKeys()) {
String settingName = "reindex.ssl." + key;
final Setting.Property[] properties = SslConfigurationKeys.isDeprecated(key) ? deprecatedProperties : defaultProperties;
final Setting.Property[] properties = SslConfigurationKeys.isDeprecatedWarning(key) ? deprecatedProperties : defaultProperties;
SETTINGS.put(settingName, listSetting(settingName, Collections.emptyList(), Function.identity(), properties));
}
for (String key : SslConfigurationKeys.getSecureStringKeys()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private BootstrapSettings() {
public static final Setting<Boolean> MEMORY_LOCK_SETTING =
Setting.boolSetting("bootstrap.memory_lock", false, Property.NodeScope);
public static final Setting<Boolean> SYSTEM_CALL_FILTER_SETTING =
Setting.boolSetting("bootstrap.system_call_filter", true, Property.Deprecated, Property.NodeScope);
Setting.boolSetting("bootstrap.system_call_filter", true, Property.DeprecatedWarning, Property.NodeScope);
public static final Setting<Boolean> CTRLHANDLER_SETTING =
Setting.boolSetting("bootstrap.ctrlhandler", true, Property.NodeScope);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public static APIBlock readFrom(StreamInput input) throws IOException {
public static final String SETTING_HISTORY_UUID = "index.history.uuid";
public static final String SETTING_DATA_PATH = "index.data_path";
public static final Setting<String> INDEX_DATA_PATH_SETTING =
new Setting<>(SETTING_DATA_PATH, "", Function.identity(), Property.IndexScope, Property.Deprecated);
new Setting<>(SETTING_DATA_PATH, "", Function.identity(), Property.IndexScope, Property.DeprecatedWarning);
public static final String INDEX_UUID_NA_VALUE = "_na_";

public static final String INDEX_ROUTING_REQUIRE_GROUP_PREFIX = "index.routing.allocation.require";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public abstract class SecureSetting<T> extends Setting<T> {
/** Determines whether legacy settings with sensitive values should be allowed. */
private static final boolean ALLOW_INSECURE_SETTINGS = Booleans.parseBoolean(System.getProperty("es.allow_insecure_settings", "false"));

private static final Set<Property> ALLOWED_PROPERTIES = EnumSet.of(Property.Deprecated, Property.Consistent);
private static final Set<Property> ALLOWED_PROPERTIES = EnumSet.of(Property.Deprecated, Property.DeprecatedWarning,
Property.Consistent);

private static final Property[] FIXED_PROPERTIES = {
Property.NodeScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
public static final Setting<Boolean> CACHE_REPOSITORY_DATA = Setting.boolSetting(
"cache_repository_data",
true,
Setting.Property.Deprecated
Setting.Property.DeprecatedWarning
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.bootstrap;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.Constants;
import org.elasticsearch.cluster.coordination.ClusterBootstrapService;
Expand Down Expand Up @@ -438,15 +439,15 @@ boolean isSystemCallFilterInstalled() {
containsString("system call filters failed to install; " +
"check the logs and fix your configuration or disable system call filters at your own risk"));
if (useBootstrapSystemCallFilter) {
assertWarnings("[bootstrap.system_call_filter] setting was deprecated in Elasticsearch " +
assertWarnings(Level.WARN, "[bootstrap.system_call_filter] setting was deprecated in Elasticsearch " +
"and will be removed in a future release!" +
" See the breaking changes documentation for the next major version.");
}

isSystemCallFilterInstalled.set(true);
BootstrapChecks.check(context, true, Collections.singletonList(systemCallFilterEnabledCheck));
if (useBootstrapSystemCallFilter) {
assertWarnings("[bootstrap.system_call_filter] setting was deprecated in Elasticsearch " +
assertWarnings(Level.WARN, "[bootstrap.system_call_filter] setting was deprecated in Elasticsearch " +
"and will be removed in a future release!" +
" See the breaking changes documentation for the next major version.");
}
Expand All @@ -460,11 +461,13 @@ boolean isSystemCallFilterInstalled() {
};
isSystemCallFilterInstalled.set(false);
BootstrapChecks.check(context_1, true, Collections.singletonList(systemCallFilterNotEnabledCheck));
assertWarnings("[bootstrap.system_call_filter] setting was deprecated in Elasticsearch and will be removed in a future release!" +
assertWarnings(Level.WARN, "[bootstrap.system_call_filter] setting was deprecated in Elasticsearch and will be removed in a " +
"future release!" +
" See the breaking changes documentation for the next major version.");
isSystemCallFilterInstalled.set(true);
BootstrapChecks.check(context_1, true, Collections.singletonList(systemCallFilterNotEnabledCheck));
assertWarnings("[bootstrap.system_call_filter] setting was deprecated in Elasticsearch and will be removed in a future release!" +
assertWarnings(Level.WARN, "[bootstrap.system_call_filter] setting was deprecated in Elasticsearch and will be removed in a " +
"future release!" +
" See the breaking changes documentation for the next major version.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,15 @@ protected final void assertSettingDeprecationsAndWarnings(final Setting<?>[] set
.toArray(DeprecationWarning[]::new));
}

/**
* Convenience method to assert warnings at a specific level for settings deprecations and general deprecation warnings.
* @param expectedWarnings expected general deprecation warnings.
*/
protected final void assertWarnings(Level level, String... expectedWarnings) {
assertWarnings(true, Arrays.stream(expectedWarnings).map(expectedWarning -> new DeprecationWarning(level,
expectedWarning)).toArray(DeprecationWarning[]::new));
}

/**
* Convenience method to assert warnings for settings deprecations and general deprecation warnings. All warnings passed to this method
* are assumed to be at DeprecationLogger.CRITICAL level.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.elasticsearch.xpack.monitoring.collector.ccr;

import org.apache.logging.log4j.Level;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.service.ClusterService;
Expand Down Expand Up @@ -150,8 +151,8 @@ public void testDoCollect() throws Exception {
assertThat(document.getId(), nullValue());
assertThat(document.stats(), is(autoFollowStats));

assertWarnings("[xpack.monitoring.collection.ccr.stats.timeout] setting was deprecated in Elasticsearch and will be removed in " +
"a future release! See the breaking changes documentation for the next major version.");
assertWarnings(Level.WARN, "[xpack.monitoring.collection.ccr.stats.timeout] setting was deprecated in Elasticsearch and will " +
"be removed in a future release! See the breaking changes documentation for the next major version.");
}

private List<FollowStatsAction.StatsResponse> mockStatuses() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class LifecycleSettings {
true, Setting.Property.NodeScope);
public static final Setting<TimeValue> LIFECYCLE_STEP_MASTER_TIMEOUT_SETTING =
Setting.positiveTimeSetting(LIFECYCLE_STEP_MASTER_TIMEOUT, TimeValue.timeValueSeconds(30), Setting.Property.Dynamic,
Setting.Property.NodeScope, Setting.Property.Deprecated);
Setting.Property.NodeScope, Setting.Property.DeprecatedWarning);
// This setting configures how much time since step_time should ILM wait for a condition to be met. After the threshold wait time has
// elapsed ILM will likely stop waiting and go to the next step.
// Also see {@link org.elasticsearch.xpack.core.ilm.ClusterStateWaitUntilThresholdStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public final class MonitoringField {
public static final Setting<TimeValue> HISTORY_DURATION = timeSetting("xpack.monitoring.history.duration",
TimeValue.timeValueHours(7 * 24), // default value (7 days)
HISTORY_DURATION_MINIMUM, // minimum value
Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);
Setting.Property.Dynamic, Setting.Property.NodeScope,
Setting.Property.DeprecatedWarning);

private MonitoringField() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class LdapUserSearchSessionFactorySettings {
public static final Setting.AffixSetting<String> SEARCH_ATTRIBUTE = Setting.affixKeySetting(
RealmSettings.realmSettingPrefix(LDAP_TYPE), "user_search.attribute",
key -> new Setting<>(key, LdapUserSearchSessionFactorySettings.DEFAULT_USERNAME_ATTRIBUTE, Function.identity(),
Setting.Property.NodeScope, Setting.Property.Deprecated));
Setting.Property.NodeScope, Setting.Property.DeprecatedWarning));

public static final Setting.AffixSetting<String> SEARCH_BASE_DN
= RealmSettings.simpleString(LDAP_TYPE, "user_search.base_dn", Setting.Property.NodeScope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class PoolingSessionFactorySettings {

public static final Function<String, Setting.AffixSetting<SecureString>> LEGACY_BIND_PASSWORD = RealmSettings.affixSetting(
"bind_password", key -> new Setting<>(key, "", SecureString::new,
Setting.Property.NodeScope, Setting.Property.Filtered, Setting.Property.Deprecated));
Setting.Property.NodeScope, Setting.Property.Filtered, Setting.Property.DeprecatedWarning));

public static final Function<String, Setting.AffixSetting<SecureString>> SECURE_BIND_PASSWORD = realmType ->
Setting.affixKeySetting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public final class SessionFactorySettings {

public static final Function<String, Setting.AffixSetting<TimeValue>> TIMEOUT_TCP_READ_SETTING = RealmSettings.affixSetting(
"timeout.tcp_read", key -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Setting.Property.NodeScope,
Setting.Property.Deprecated));
Setting.Property.DeprecatedWarning));

public static final Function<String, Setting.AffixSetting<TimeValue>> TIMEOUT_RESPONSE_SETTING = RealmSettings.affixSetting(
"timeout.response", key -> Setting.timeSetting(key, TimeValue.MINUS_ONE, Setting.Property.NodeScope));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public class SSLConfigurationSettings {
Setting.affixKeySetting("xpack.security.authc.realms." + realmType + ".", "ssl.key", X509KeyPairSettings.KEY_PATH_TEMPLATE);

public static final Function<String, Setting<SecureString>> LEGACY_TRUSTSTORE_PASSWORD_TEMPLATE = key ->
new Setting<>(key, "", SecureString::new, Property.Deprecated, Property.Filtered, Property.NodeScope);
new Setting<>(key, "", SecureString::new, Property.DeprecatedWarning, Property.Filtered, Property.NodeScope);
public static final Setting<SecureString> LEGACY_TRUSTSTORE_PASSWORD_PROFILES = Setting.affixKeySetting("transport.profiles.",
"xpack.security.ssl.truststore.password", LEGACY_TRUSTSTORE_PASSWORD_TEMPLATE);
public static final Function<String, Setting.AffixSetting<SecureString>> LEGACY_TRUST_STORE_PASSWORD_REALM = realmType ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class X509KeyPairSettings {
Optional::ofNullable, Setting.Property.NodeScope, Setting.Property.Filtered);

static final Function<String, Setting<SecureString>> LEGACY_KEYSTORE_PASSWORD_TEMPLATE = key -> new Setting<>(key, "",
SecureString::new, Setting.Property.Deprecated, Setting.Property.Filtered, Setting.Property.NodeScope);
SecureString::new, Setting.Property.DeprecatedWarning, Setting.Property.Filtered, Setting.Property.NodeScope);
static final Function<String, Setting<SecureString>> KEYSTORE_PASSWORD_TEMPLATE = key -> SecureSetting.secureString(key,
LEGACY_KEYSTORE_PASSWORD_TEMPLATE.apply(key.replace("keystore.secure_password", "keystore.password")));

Expand All @@ -44,7 +44,7 @@ public class X509KeyPairSettings {
new Setting<>(key, s -> null, Optional::ofNullable, Setting.Property.NodeScope, Setting.Property.Filtered);

static final Function<String, Setting<SecureString>> LEGACY_KEYSTORE_KEY_PASSWORD_TEMPLATE = key -> new Setting<>(key, "",
SecureString::new, Setting.Property.Deprecated, Setting.Property.Filtered, Setting.Property.NodeScope);
SecureString::new, Setting.Property.DeprecatedWarning, Setting.Property.Filtered, Setting.Property.NodeScope);
static final Function<String, Setting<SecureString>> KEYSTORE_KEY_PASSWORD_TEMPLATE = key ->
SecureSetting.secureString(key, LEGACY_KEYSTORE_KEY_PASSWORD_TEMPLATE.apply(key.replace("keystore.secure_key_password",
"keystore.key_password")));
Expand All @@ -56,7 +56,7 @@ public class X509KeyPairSettings {
Optional::ofNullable, Setting.Property.NodeScope, Setting.Property.Filtered);

static final Function<String, Setting<SecureString>> LEGACY_KEY_PASSWORD_TEMPLATE = key -> new Setting<>(key, "",
SecureString::new, Setting.Property.Deprecated, Setting.Property.Filtered, Setting.Property.NodeScope);
SecureString::new, Setting.Property.DeprecatedWarning, Setting.Property.Filtered, Setting.Property.NodeScope);
static final Function<String, Setting<SecureString>> KEY_PASSWORD_TEMPLATE = key ->
SecureSetting.secureString(key, LEGACY_KEY_PASSWORD_TEMPLATE.apply(key.replace("secure_key_passphrase",
"key_passphrase")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.elasticsearch.xpack.monitoring.collector.enrich;

import org.apache.logging.log4j.Level;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.service.ClusterService;
Expand Down Expand Up @@ -142,6 +143,7 @@ public void testDoCollect() throws Exception {
}

assertWarnings(
Level.WARN,
"[xpack.monitoring.collection.enrich.stats.timeout] setting was deprecated in Elasticsearch and will be removed "
+ "in a future release! See the breaking changes documentation for the next major version."
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class EqlPlugin extends Plugin implements ActionPlugin, CircuitBreakerPlu
"xpack.eql.enabled",
true,
Setting.Property.NodeScope,
Setting.Property.Deprecated
Setting.Property.DeprecatedWarning
);

public EqlPlugin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class Monitoring extends Plugin implements ActionPlugin, ReloadablePlugin
true, Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);

public static final Setting<Boolean> MIGRATION_DECOMMISSION_ALERTS = boolSetting("xpack.monitoring.migration.decommission_alerts",
false, Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);
false, Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.DeprecatedWarning);

public static final LicensedFeature.Momentary MONITORING_CLUSTER_ALERTS_FEATURE =
LicensedFeature.momentary("monitoring", "cluster-alerts", License.OperationMode.STANDARD);
Expand Down

0 comments on commit 6e3a108

Please sign in to comment.