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 deprecation info API checks for delay cluster state recovery settings #77042

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 @@ -97,6 +97,7 @@ private DeprecationChecks() {
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
NodeDeprecationChecks::checkSearchRemoteSettings,
NodeDeprecationChecks::checkMonitoringExporterPassword,
NodeDeprecationChecks::checkDelayClusterStateRecoverySettings,
NodeDeprecationChecks::checkFixedAutoQueueSizeThreadpool,
NodeDeprecationChecks::checkJoinTimeoutSetting,
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.jdk.JavaVersion;
import org.elasticsearch.license.License;
import org.elasticsearch.license.XPackLicenseState;
Expand Down Expand Up @@ -665,6 +666,36 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
);
}

static DeprecationIssue checkDelayClusterStateRecoverySettings(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
List<Setting<Integer>> deprecatedSettings = new ArrayList<>();
deprecatedSettings.add(GatewayService.EXPECTED_NODES_SETTING);
deprecatedSettings.add(GatewayService.EXPECTED_MASTER_NODES_SETTING);
deprecatedSettings.add(GatewayService.RECOVER_AFTER_NODES_SETTING);
deprecatedSettings.add(GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING);
List<Setting<Integer>> existingSettings =
deprecatedSettings.stream().filter(deprecatedSetting -> deprecatedSetting.exists(settings)).collect(Collectors.toList());
if (existingSettings.isEmpty()) {
return null;
}
final String settingNames = existingSettings.stream().map(Setting::getKey).collect(Collectors.joining(","));
final String message = String.format(
Locale.ROOT,
"cannot use properties related to delaying cluster state recovery after a majority of master nodes have joined because " +
"they have been deprecated and will be removed in the next major version",
settingNames
);
final String details = String.format(
Locale.ROOT,
"cannot use properties [%s] because they have been deprecated and will be removed in the next major version",
settingNames
);
final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes";
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
}

static DeprecationIssue checkFixedAutoQueueSizeThreadpool(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
Expand Down Expand Up @@ -769,9 +800,9 @@ static DeprecationIssue checkRolesCacheTTLSizeSetting(final Settings settings,
}

static DeprecationIssue checkMaxLocalStorageNodesSetting(final Settings settings,
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
final PluginsAndModules pluginsAndModules,
final ClusterState clusterState,
final XPackLicenseState licenseState) {
return checkRemovedSetting(settings,
NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING,
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_node_changes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.core.Set;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.jdk.JavaVersion;
import org.elasticsearch.license.License;
import org.elasticsearch.license.XPackLicenseState;
Expand Down Expand Up @@ -961,6 +962,32 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() {
assertThat(issues, empty());
}

public void testCheckDelayClusterStateRecoverySettings() {
Settings settings = Settings.builder()
.put(GatewayService.EXPECTED_NODES_SETTING.getKey(), randomIntBetween(2, 10))
.put(GatewayService.EXPECTED_MASTER_NODES_SETTING.getKey(), randomIntBetween(2, 10))
.put(GatewayService.RECOVER_AFTER_NODES_SETTING.getKey(), randomIntBetween(2, 10))
.put(GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING.getKey(), randomIntBetween(2, 10))
.build();
final ClusterState clusterState = ClusterState.EMPTY_STATE;
final DeprecationIssue expectedIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"cannot use properties related to delaying cluster state recovery after a majority of master nodes have joined because they " +
"have been deprecated and will be removed in the next major version",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
"cannot use properties [gateway.expected_nodes,gateway.expected_master_nodes,gateway.recover_after_nodes,gateway" +
".recover_after_master_nodes] because they have been deprecated and will be removed in the next major version",
false, null
);
final XPackLicenseState licenseState = mock(XPackLicenseState.class);
when(licenseState.getOperationMode())
.thenReturn(randomValueOtherThanMany((m -> m.equals(License.OperationMode.BASIC) || m.equals(License.OperationMode.TRIAL)),
() -> randomFrom(License.OperationMode.values())));
assertThat(
NodeDeprecationChecks.checkDelayClusterStateRecoverySettings(settings, null, clusterState, licenseState),
equalTo(expectedIssue)
);
}

public void testCheckFixedAutoQueueSizeThreadpool() {
String settingKey = "thread_pool.search.min_queue_size";
String settingValue = "";
Expand Down Expand Up @@ -1123,5 +1150,4 @@ public void testCheckMaxLocalStorageNodesSetting() {
String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_node_changes";
checkSimpleSetting(settingKey, settingValue, url, NodeDeprecationChecks::checkMaxLocalStorageNodesSetting);
}

}