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 1 commit
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 @@ -95,6 +95,7 @@ private DeprecationChecks() {
NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting,
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
NodeDeprecationChecks::checkMonitoringExporterPassword,
NodeDeprecationChecks::checkFrozenCacheLeniency,
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting
)
).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.env.Environment;
Expand All @@ -30,6 +31,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.xpack.core.XPackSettings;
import org.elasticsearch.xpack.core.security.authc.RealmConfig;
import org.elasticsearch.xpack.core.security.authc.RealmSettings;
Expand Down Expand Up @@ -595,4 +597,28 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
DeprecationIssue.Level.CRITICAL
);
}

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -863,4 +863,68 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() {
final List<DeprecationIssue> issues = getDeprecationIssues(settings, pluginsAndModules, licenseState);
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)
);
}
}