Skip to content
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 node deprecation info API check for frozen cache setting #77085

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double checking here because I know that -1 usually means "disabled": Is this expected to be 0 or negative, or should it be always negative?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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