Skip to content

Commit 51fde90

Browse files
authored
Adding deprecation info API checks for delay cluster state recovery settings (#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
1 parent 83355d3 commit 51fde90

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
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
@@ -97,6 +97,7 @@ private DeprecationChecks() {
9797
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
9898
NodeDeprecationChecks::checkSearchRemoteSettings,
9999
NodeDeprecationChecks::checkMonitoringExporterPassword,
100+
NodeDeprecationChecks::checkDelayClusterStateRecoverySettings,
100101
NodeDeprecationChecks::checkFixedAutoQueueSizeThreadpool,
101102
NodeDeprecationChecks::checkJoinTimeoutSetting,
102103
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting,

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.core.TimeValue;
2626
import org.elasticsearch.env.Environment;
2727
import org.elasticsearch.env.NodeEnvironment;
28+
import org.elasticsearch.gateway.GatewayService;
2829
import org.elasticsearch.jdk.JavaVersion;
2930
import org.elasticsearch.license.License;
3031
import org.elasticsearch.license.XPackLicenseState;
@@ -665,6 +666,36 @@ static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(f
665666
);
666667
}
667668

669+
static DeprecationIssue checkDelayClusterStateRecoverySettings(final Settings settings,
670+
final PluginsAndModules pluginsAndModules,
671+
final ClusterState clusterState,
672+
final XPackLicenseState licenseState) {
673+
List<Setting<Integer>> deprecatedSettings = new ArrayList<>();
674+
deprecatedSettings.add(GatewayService.EXPECTED_NODES_SETTING);
675+
deprecatedSettings.add(GatewayService.EXPECTED_MASTER_NODES_SETTING);
676+
deprecatedSettings.add(GatewayService.RECOVER_AFTER_NODES_SETTING);
677+
deprecatedSettings.add(GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING);
678+
List<Setting<Integer>> existingSettings =
679+
deprecatedSettings.stream().filter(deprecatedSetting -> deprecatedSetting.exists(settings)).collect(Collectors.toList());
680+
if (existingSettings.isEmpty()) {
681+
return null;
682+
}
683+
final String settingNames = existingSettings.stream().map(Setting::getKey).collect(Collectors.joining(","));
684+
final String message = String.format(
685+
Locale.ROOT,
686+
"cannot use properties related to delaying cluster state recovery after a majority of master nodes have joined because " +
687+
"they have been deprecated and will be removed in the next major version",
688+
settingNames
689+
);
690+
final String details = String.format(
691+
Locale.ROOT,
692+
"cannot use properties [%s] because they have been deprecated and will be removed in the next major version",
693+
settingNames
694+
);
695+
final String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes";
696+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
697+
}
698+
668699
static DeprecationIssue checkFixedAutoQueueSizeThreadpool(final Settings settings,
669700
final PluginsAndModules pluginsAndModules,
670701
final ClusterState clusterState,
@@ -769,9 +800,9 @@ static DeprecationIssue checkRolesCacheTTLSizeSetting(final Settings settings,
769800
}
770801

771802
static DeprecationIssue checkMaxLocalStorageNodesSetting(final Settings settings,
772-
final PluginsAndModules pluginsAndModules,
773-
final ClusterState clusterState,
774-
final XPackLicenseState licenseState) {
803+
final PluginsAndModules pluginsAndModules,
804+
final ClusterState clusterState,
805+
final XPackLicenseState licenseState) {
775806
return checkRemovedSetting(settings,
776807
NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING,
777808
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_node_changes",

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.core.Set;
2424
import org.elasticsearch.env.Environment;
2525
import org.elasticsearch.env.NodeEnvironment;
26+
import org.elasticsearch.gateway.GatewayService;
2627
import org.elasticsearch.jdk.JavaVersion;
2728
import org.elasticsearch.license.License;
2829
import org.elasticsearch.license.XPackLicenseState;
@@ -961,6 +962,32 @@ public void testImplicitlyConfiguredSecurityOnGoldPlus() {
961962
assertThat(issues, empty());
962963
}
963964

965+
public void testCheckDelayClusterStateRecoverySettings() {
966+
Settings settings = Settings.builder()
967+
.put(GatewayService.EXPECTED_NODES_SETTING.getKey(), randomIntBetween(2, 10))
968+
.put(GatewayService.EXPECTED_MASTER_NODES_SETTING.getKey(), randomIntBetween(2, 10))
969+
.put(GatewayService.RECOVER_AFTER_NODES_SETTING.getKey(), randomIntBetween(2, 10))
970+
.put(GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING.getKey(), randomIntBetween(2, 10))
971+
.build();
972+
final ClusterState clusterState = ClusterState.EMPTY_STATE;
973+
final DeprecationIssue expectedIssue = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
974+
"cannot use properties related to delaying cluster state recovery after a majority of master nodes have joined because they " +
975+
"have been deprecated and will be removed in the next major version",
976+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes",
977+
"cannot use properties [gateway.expected_nodes,gateway.expected_master_nodes,gateway.recover_after_nodes,gateway" +
978+
".recover_after_master_nodes] because they have been deprecated and will be removed in the next major version",
979+
false, null
980+
);
981+
final XPackLicenseState licenseState = mock(XPackLicenseState.class);
982+
when(licenseState.getOperationMode())
983+
.thenReturn(randomValueOtherThanMany((m -> m.equals(License.OperationMode.BASIC) || m.equals(License.OperationMode.TRIAL)),
984+
() -> randomFrom(License.OperationMode.values())));
985+
assertThat(
986+
NodeDeprecationChecks.checkDelayClusterStateRecoverySettings(settings, null, clusterState, licenseState),
987+
equalTo(expectedIssue)
988+
);
989+
}
990+
964991
public void testCheckFixedAutoQueueSizeThreadpool() {
965992
String settingKey = "thread_pool.search.min_queue_size";
966993
String settingValue = "";
@@ -1123,5 +1150,4 @@ public void testCheckMaxLocalStorageNodesSetting() {
11231150
String url = "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_node_changes";
11241151
checkSimpleSetting(settingKey, settingValue, url, NodeDeprecationChecks::checkMaxLocalStorageNodesSetting);
11251152
}
1126-
11271153
}

0 commit comments

Comments
 (0)