Skip to content

Commit

Permalink
Adding deprecation info API checks for delay cluster state recovery s…
Browse files Browse the repository at this point in the history
…ettings (#77042)

The ability to delay cluster state recovery once a majority of master eligible nodes has joined has
been removed in 8.0. This commit checks for settings that are related, and issues a deprecation
info API message about it.
Relates #42404 #53845
  • Loading branch information
masseyke authored Sep 2, 2021
1 parent 83355d3 commit 51fde90
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
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);
}

}

0 comments on commit 51fde90

Please sign in to comment.