Skip to content

Commit

Permalink
Adding node deprecation info API check for frozen cache setting (#77085)
Browse files Browse the repository at this point in the history
In 8.0 the ability to have a positive "xpack.searchable.snapshot.shared_cache.size" on a non-frozen node
has been removed. This commit adds a deprecation info API check if a non-frozen node has a positive
 "xpack.searchable.snapshot.shared_cache.size".
Relates #42404 #71013
  • Loading branch information
masseyke authored Sep 3, 2021
1 parent ba9bc17 commit 783afbc
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private DeprecationChecks() {
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
NodeDeprecationChecks::checkSearchRemoteSettings,
NodeDeprecationChecks::checkMonitoringExporterPassword,
NodeDeprecationChecks::checkFrozenCacheLeniency,
NodeDeprecationChecks::checkSslServerEnabled,
NodeDeprecationChecks::checkSslCertConfiguration,
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.set.Sets;
Expand All @@ -35,6 +36,7 @@
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.XPackSettings;
Expand Down Expand Up @@ -669,6 +671,30 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
);
}

static DeprecationIssue checkFrozenCacheLeniency(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
final String cacheSizeSettingKey = "xpack.searchable.snapshot.shared_cache.size";
Setting<ByteSizeValue> cacheSizeSetting = Setting.byteSizeSetting(cacheSizeSettingKey, ByteSizeValue.ZERO);
if (cacheSizeSetting.exists(settings)) {
ByteSizeValue cacheSize = cacheSizeSetting.get(settings);
if (cacheSize.getBytes() > 0) {
final List<DiscoveryNodeRole> roles = NodeRoleSettings.NODE_ROLES_SETTING.get(settings);
if (DataTier.isFrozenNode(new HashSet<>(roles)) == false) {
String message = String.format(Locale.ROOT, "setting [%s] cannot be greater than zero on non-frozen nodes",
cacheSizeSettingKey);
String url =
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes";
String details = String.format(Locale.ROOT, "setting [%s] cannot be greater than zero on non-frozen nodes, and is " +
"currently set to [%s]", cacheSizeSettingKey, settings.get(cacheSizeSettingKey));
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
}
}
}
return null;
}

static DeprecationIssue checkSslServerEnabled(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,70 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() {
assertThat(issues, empty());
}

public void testCheckFrozenCacheLeniency() {
String cacheSizeSettingValue = "10gb";
String cacheSizeSettingKey = "xpack.searchable.snapshot.shared_cache.size";
Settings nodeSettings = Settings.builder()
.put(cacheSizeSettingKey, cacheSizeSettingValue)
.put("node.roles", "data_warm")
.build();
final XPackLicenseState licenseState = new XPackLicenseState(Settings.EMPTY, () -> 0);
final ClusterState clusterState = ClusterState.EMPTY_STATE;
DeprecationIssue expectedIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
String.format(Locale.ROOT,
"setting [%s] cannot be greater than zero on non-frozen nodes",
cacheSizeSettingKey),
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
String.format(Locale.ROOT,
"setting [%s] cannot be greater than zero on non-frozen nodes, and is currently set to [%s]",
cacheSizeSettingKey,
cacheSizeSettingValue),
false,null
);
assertThat(
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
equalTo(expectedIssue)
);

// If no 'node.roles' is specified, a node gets all roles:
nodeSettings = Settings.builder()
.put(cacheSizeSettingKey, cacheSizeSettingValue)
.build();
assertThat(
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
equalTo(null)
);

// No deprecation warning on a frozen node:
nodeSettings = Settings.builder()
.put(cacheSizeSettingKey, cacheSizeSettingValue)
.put("node.roles", "data_frozen")
.build();
assertThat(
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
equalTo(null)
);

// No cache size specified, so no deprecation warning:
nodeSettings = Settings.builder()
.put("node.roles", "data_warm")
.build();
assertThat(
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
equalTo(null)
);

// Cache size is not positive, so no deprecation wawrning:
nodeSettings = Settings.builder()
.put(cacheSizeSettingKey, "0b")
.put("node.roles", "data_warm")
.build();
assertThat(
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
equalTo(null)
);
}

public void testCheckSslServerEnabled() {
String httpSslEnabledKey = "xpack.security.http.ssl.enabled";
String transportSslEnabledKey = "xpack.security.transport.ssl.enabled";
Expand Down

0 comments on commit 783afbc

Please sign in to comment.