Skip to content

Commit 783afbc

Browse files
authored
Adding node deprecation info API check for frozen cache setting (#77085)
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
1 parent ba9bc17 commit 783afbc

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ private DeprecationChecks() {
9898
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
9999
NodeDeprecationChecks::checkSearchRemoteSettings,
100100
NodeDeprecationChecks::checkMonitoringExporterPassword,
101+
NodeDeprecationChecks::checkFrozenCacheLeniency,
101102
NodeDeprecationChecks::checkSslServerEnabled,
102103
NodeDeprecationChecks::checkSslCertConfiguration,
103104
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting,

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.elasticsearch.common.settings.Setting;
2121
import org.elasticsearch.common.settings.Setting.Property;
2222
import org.elasticsearch.common.settings.Settings;
23+
import org.elasticsearch.common.unit.ByteSizeValue;
2324
import org.elasticsearch.common.ssl.SslConfigurationKeys;
2425
import org.elasticsearch.common.util.concurrent.EsExecutors;
2526
import org.elasticsearch.common.util.set.Sets;
@@ -35,6 +36,7 @@
3536
import org.elasticsearch.script.ScriptService;
3637
import org.elasticsearch.threadpool.FixedExecutorBuilder;
3738
import org.elasticsearch.transport.RemoteClusterService;
39+
import org.elasticsearch.xpack.core.DataTier;
3840
import org.elasticsearch.transport.SniffConnectionStrategy;
3941
import org.elasticsearch.transport.TransportService;
4042
import org.elasticsearch.xpack.core.XPackSettings;
@@ -669,6 +671,30 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
669671
);
670672
}
671673

674+
static DeprecationIssue checkFrozenCacheLeniency(final Settings settings,
675+
final PluginsAndModules pluginsAndModules,
676+
final ClusterState clusterState,
677+
final XPackLicenseState licenseState) {
678+
final String cacheSizeSettingKey = "xpack.searchable.snapshot.shared_cache.size";
679+
Setting<ByteSizeValue> cacheSizeSetting = Setting.byteSizeSetting(cacheSizeSettingKey, ByteSizeValue.ZERO);
680+
if (cacheSizeSetting.exists(settings)) {
681+
ByteSizeValue cacheSize = cacheSizeSetting.get(settings);
682+
if (cacheSize.getBytes() > 0) {
683+
final List<DiscoveryNodeRole> roles = NodeRoleSettings.NODE_ROLES_SETTING.get(settings);
684+
if (DataTier.isFrozenNode(new HashSet<>(roles)) == false) {
685+
String message = String.format(Locale.ROOT, "setting [%s] cannot be greater than zero on non-frozen nodes",
686+
cacheSizeSettingKey);
687+
String url =
688+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes";
689+
String details = String.format(Locale.ROOT, "setting [%s] cannot be greater than zero on non-frozen nodes, and is " +
690+
"currently set to [%s]", cacheSizeSettingKey, settings.get(cacheSizeSettingKey));
691+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
692+
}
693+
}
694+
}
695+
return null;
696+
}
697+
672698
static DeprecationIssue checkSslServerEnabled(final Settings settings,
673699
final PluginsAndModules pluginsAndModules,
674700
final ClusterState clusterState,

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,70 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() {
963963
assertThat(issues, empty());
964964
}
965965

966+
public void testCheckFrozenCacheLeniency() {
967+
String cacheSizeSettingValue = "10gb";
968+
String cacheSizeSettingKey = "xpack.searchable.snapshot.shared_cache.size";
969+
Settings nodeSettings = Settings.builder()
970+
.put(cacheSizeSettingKey, cacheSizeSettingValue)
971+
.put("node.roles", "data_warm")
972+
.build();
973+
final XPackLicenseState licenseState = new XPackLicenseState(Settings.EMPTY, () -> 0);
974+
final ClusterState clusterState = ClusterState.EMPTY_STATE;
975+
DeprecationIssue expectedIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
976+
String.format(Locale.ROOT,
977+
"setting [%s] cannot be greater than zero on non-frozen nodes",
978+
cacheSizeSettingKey),
979+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
980+
String.format(Locale.ROOT,
981+
"setting [%s] cannot be greater than zero on non-frozen nodes, and is currently set to [%s]",
982+
cacheSizeSettingKey,
983+
cacheSizeSettingValue),
984+
false,null
985+
);
986+
assertThat(
987+
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
988+
equalTo(expectedIssue)
989+
);
990+
991+
// If no 'node.roles' is specified, a node gets all roles:
992+
nodeSettings = Settings.builder()
993+
.put(cacheSizeSettingKey, cacheSizeSettingValue)
994+
.build();
995+
assertThat(
996+
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
997+
equalTo(null)
998+
);
999+
1000+
// No deprecation warning on a frozen node:
1001+
nodeSettings = Settings.builder()
1002+
.put(cacheSizeSettingKey, cacheSizeSettingValue)
1003+
.put("node.roles", "data_frozen")
1004+
.build();
1005+
assertThat(
1006+
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
1007+
equalTo(null)
1008+
);
1009+
1010+
// No cache size specified, so no deprecation warning:
1011+
nodeSettings = Settings.builder()
1012+
.put("node.roles", "data_warm")
1013+
.build();
1014+
assertThat(
1015+
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
1016+
equalTo(null)
1017+
);
1018+
1019+
// Cache size is not positive, so no deprecation wawrning:
1020+
nodeSettings = Settings.builder()
1021+
.put(cacheSizeSettingKey, "0b")
1022+
.put("node.roles", "data_warm")
1023+
.build();
1024+
assertThat(
1025+
NodeDeprecationChecks.checkFrozenCacheLeniency(nodeSettings, null, clusterState, licenseState),
1026+
equalTo(null)
1027+
);
1028+
}
1029+
9661030
public void testCheckSslServerEnabled() {
9671031
String httpSslEnabledKey = "xpack.security.http.ssl.enabled";
9681032
String transportSslEnabledKey = "xpack.security.transport.ssl.enabled";

0 commit comments

Comments
 (0)