Skip to content

Commit fc1749b

Browse files
authored
adding a deprecation info check for search.remote properties (#76954)
The search.remote.* properties have been removed in 8.0 and replaced with cluster.remote.* properties. This adds a check for these properties in the deprecation info API. Relates #42404 and #42381
1 parent 4603a29 commit fc1749b

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ private DeprecationChecks() {
9595
NodeDeprecationChecks::checkSharedDataPathSetting,
9696
NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting,
9797
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
98+
NodeDeprecationChecks::checkSearchRemoteSettings,
9899
NodeDeprecationChecks::checkMonitoringExporterPassword,
99100
NodeDeprecationChecks::checkAcceptDefaultPasswordSetting,
100101
NodeDeprecationChecks::checkAcceptRolesCacheMaxSizeSetting,

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

+45
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.script.ScriptService;
3232
import org.elasticsearch.threadpool.FixedExecutorBuilder;
3333
import org.elasticsearch.transport.RemoteClusterService;
34+
import org.elasticsearch.transport.SniffConnectionStrategy;
3435
import org.elasticsearch.xpack.core.XPackSettings;
3536
import org.elasticsearch.xpack.core.security.SecurityField;
3637
import org.elasticsearch.xpack.core.security.authc.RealmConfig;
@@ -593,6 +594,50 @@ static DeprecationIssue checkMonitoringExporterPassword(
593594
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
594595
}
595596

597+
static DeprecationIssue checkSearchRemoteSettings(
598+
final Settings settings,
599+
final PluginsAndModules pluginsAndModules,
600+
ClusterState cs,
601+
XPackLicenseState licenseState
602+
) {
603+
List<Setting<?>> remoteClusterSettings = new ArrayList<>();
604+
remoteClusterSettings.addAll(SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_SEEDS.getAllConcreteSettings(settings)
605+
.sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList()));
606+
remoteClusterSettings.addAll(SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY.getAllConcreteSettings(settings)
607+
.sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList()));
608+
remoteClusterSettings.addAll(RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getAllConcreteSettings(settings)
609+
.sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList()));
610+
if (SniffConnectionStrategy.SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER.exists(settings)) {
611+
remoteClusterSettings.add(SniffConnectionStrategy.SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER);
612+
}
613+
if (RemoteClusterService.SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.exists(settings)) {
614+
remoteClusterSettings.add(RemoteClusterService.SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING);
615+
}
616+
if (RemoteClusterService.SEARCH_REMOTE_NODE_ATTRIBUTE.exists(settings)) {
617+
remoteClusterSettings.add(RemoteClusterService.SEARCH_REMOTE_NODE_ATTRIBUTE);
618+
}
619+
if (RemoteClusterService.SEARCH_ENABLE_REMOTE_CLUSTERS.exists(settings)) {
620+
remoteClusterSettings.add(RemoteClusterService.SEARCH_ENABLE_REMOTE_CLUSTERS);
621+
}
622+
if (remoteClusterSettings.isEmpty()) {
623+
return null;
624+
}
625+
final String remoteClusterSeedSettings = remoteClusterSettings.stream().map(Setting::getKey).collect(Collectors.joining(","));
626+
final String message = String.format(
627+
Locale.ROOT,
628+
"search.remote settings [%s] are deprecated and will be removed in the next major version",
629+
remoteClusterSeedSettings
630+
);
631+
final String details = String.format(
632+
Locale.ROOT,
633+
"replace search.remote settings [%s] with their secure 'cluster.remote' replacements",
634+
remoteClusterSeedSettings
635+
);
636+
final String url =
637+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes";
638+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null);
639+
}
640+
596641
static DeprecationIssue checkClusterRoutingAllocationIncludeRelocationsSetting(final Settings settings,
597642
final PluginsAndModules pluginsAndModules,
598643
final ClusterState clusterState,

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

+58
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,64 @@ public void testMonitoringExporterPassword() {
798798
assertThat(issue, nullValue());
799799
}
800800

801+
public void testCheckSearchRemoteSettings() {
802+
// test for presence of deprecated exporter passwords
803+
final int numClusters = randomIntBetween(1, 3);
804+
final String[] clusterNames = new String[numClusters];
805+
final Settings.Builder settingsBuilder = Settings.builder();
806+
for (int k = 0; k < numClusters; k++) {
807+
clusterNames[k] = randomAlphaOfLength(5);
808+
settingsBuilder.put("search.remote." + clusterNames[k] + ".seeds", randomAlphaOfLength(5));
809+
settingsBuilder.put("search.remote." + clusterNames[k] + ".proxy", randomAlphaOfLength(5));
810+
settingsBuilder.put("search.remote." + clusterNames[k] + ".skip_unavailable", randomBoolean());
811+
}
812+
settingsBuilder.put("search.remote.connections_per_cluster", randomIntBetween(0, 100));
813+
settingsBuilder.put("search.remote.initial_connect_timeout", randomIntBetween(30, 60));
814+
settingsBuilder.put("search.remote.connect", randomBoolean());
815+
final Settings settings = settingsBuilder.build();
816+
final XPackLicenseState licenseState = new XPackLicenseState(Settings.EMPTY, () -> 0);
817+
DeprecationIssue issue = NodeDeprecationChecks.checkSearchRemoteSettings(settings, null, null , licenseState);
818+
819+
final String expectedUrl =
820+
"https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes";
821+
String joinedNames = Arrays
822+
.stream(clusterNames)
823+
.map(s -> "search.remote." + s + ".seeds")
824+
.sorted()
825+
.collect(Collectors.joining(","));
826+
joinedNames += ",";
827+
joinedNames += Arrays
828+
.stream(clusterNames)
829+
.map(s -> "search.remote." + s + ".proxy")
830+
.sorted()
831+
.collect(Collectors.joining(","));
832+
joinedNames += ",";
833+
joinedNames += Arrays
834+
.stream(clusterNames)
835+
.map(s -> "search.remote." + s + ".skip_unavailable")
836+
.sorted()
837+
.collect(Collectors.joining(","));
838+
joinedNames += ",search.remote.connections_per_cluster,search.remote.initial_connect_timeout,search.remote.connect";
839+
840+
assertThat(issue, equalTo(new DeprecationIssue(
841+
DeprecationIssue.Level.CRITICAL,
842+
String.format(
843+
Locale.ROOT,
844+
"search.remote settings [%s] are deprecated and will be removed in the next major version",
845+
joinedNames
846+
),
847+
expectedUrl,
848+
String.format(
849+
Locale.ROOT,
850+
"replace search.remote settings [%s] with their secure 'cluster.remote' replacements",
851+
joinedNames
852+
), false, null)));
853+
854+
// test for absence of deprecated exporter passwords
855+
issue = NodeDeprecationChecks.checkMonitoringExporterPassword(Settings.builder().build(), null, null, licenseState);
856+
assertThat(issue, nullValue());
857+
}
858+
801859
public void testClusterRoutingAllocationIncludeRelocationsSetting() {
802860
boolean settingValue = randomBoolean();
803861
String settingKey = CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey();

0 commit comments

Comments
 (0)