diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java index 06eb504b7a61c..b66c1586c4d3d 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java @@ -95,6 +95,7 @@ private DeprecationChecks() { NodeDeprecationChecks::checkSharedDataPathSetting, NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting, NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial, + NodeDeprecationChecks::checkSearchRemoteSettings, NodeDeprecationChecks::checkMonitoringExporterPassword, NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting ) diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java index 4968eea4ed60f..ab5397705670f 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java @@ -30,6 +30,7 @@ import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.transport.RemoteClusterService; +import org.elasticsearch.transport.SniffConnectionStrategy; import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.security.authc.RealmConfig; import org.elasticsearch.xpack.core.security.authc.RealmSettings; @@ -585,6 +586,50 @@ static DeprecationIssue checkMonitoringExporterPassword( return new DeprecationIssue(DeprecationIssue.Level.CRITICAL, message, url, details, false, null); } + static DeprecationIssue checkSearchRemoteSettings( + final Settings settings, + final PluginsAndModules pluginsAndModules, + ClusterState cs, + XPackLicenseState licenseState + ) { + List> remoteClusterSettings = new ArrayList<>(); + remoteClusterSettings.addAll(SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_SEEDS.getAllConcreteSettings(settings) + .sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList())); + remoteClusterSettings.addAll(SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY.getAllConcreteSettings(settings) + .sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList())); + remoteClusterSettings.addAll(RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getAllConcreteSettings(settings) + .sorted(Comparator.comparing(Setting::getKey)).collect(Collectors.toList())); + if (SniffConnectionStrategy.SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER.exists(settings)) { + remoteClusterSettings.add(SniffConnectionStrategy.SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER); + } + if (RemoteClusterService.SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.exists(settings)) { + remoteClusterSettings.add(RemoteClusterService.SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING); + } + if (RemoteClusterService.SEARCH_REMOTE_NODE_ATTRIBUTE.exists(settings)) { + remoteClusterSettings.add(RemoteClusterService.SEARCH_REMOTE_NODE_ATTRIBUTE); + } + if (RemoteClusterService.SEARCH_ENABLE_REMOTE_CLUSTERS.exists(settings)) { + remoteClusterSettings.add(RemoteClusterService.SEARCH_ENABLE_REMOTE_CLUSTERS); + } + if (remoteClusterSettings.isEmpty()) { + return null; + } + final String remoteClusterSeedSettings = remoteClusterSettings.stream().map(Setting::getKey).collect(Collectors.joining(",")); + final String message = String.format( + Locale.ROOT, + "search.remote settings [%s] are deprecated and will be removed in the next major version", + remoteClusterSeedSettings + ); + final String details = String.format( + Locale.ROOT, + "replace search.remote settings [%s] with their secure 'cluster.remote' replacements", + remoteClusterSeedSettings + ); + 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 checkClusterRoutingAllocationIncludeRelocationsSetting(final Settings settings, final PluginsAndModules pluginsAndModules, final ClusterState clusterState, diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java index 0886f0dfe28fd..00dad7bb905d2 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java @@ -798,6 +798,64 @@ public void testMonitoringExporterPassword() { assertThat(issue, nullValue()); } + public void testCheckSearchRemoteSettings() { + // test for presence of deprecated exporter passwords + final int numClusters = randomIntBetween(1, 3); + final String[] clusterNames = new String[numClusters]; + final Settings.Builder settingsBuilder = Settings.builder(); + for (int k = 0; k < numClusters; k++) { + clusterNames[k] = randomAlphaOfLength(5); + settingsBuilder.put("search.remote." + clusterNames[k] + ".seeds", randomAlphaOfLength(5)); + settingsBuilder.put("search.remote." + clusterNames[k] + ".proxy", randomAlphaOfLength(5)); + settingsBuilder.put("search.remote." + clusterNames[k] + ".skip_unavailable", randomBoolean()); + } + settingsBuilder.put("search.remote.connections_per_cluster", randomIntBetween(0, 100)); + settingsBuilder.put("search.remote.initial_connect_timeout", randomIntBetween(30, 60)); + settingsBuilder.put("search.remote.connect", randomBoolean()); + final Settings settings = settingsBuilder.build(); + final XPackLicenseState licenseState = new XPackLicenseState(Settings.EMPTY, () -> 0); + DeprecationIssue issue = NodeDeprecationChecks.checkSearchRemoteSettings(settings, null, null , licenseState); + + final String expectedUrl = + "https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking_80_settings_changes"; + String joinedNames = Arrays + .stream(clusterNames) + .map(s -> "search.remote." + s + ".seeds") + .sorted() + .collect(Collectors.joining(",")); + joinedNames += ","; + joinedNames += Arrays + .stream(clusterNames) + .map(s -> "search.remote." + s + ".proxy") + .sorted() + .collect(Collectors.joining(",")); + joinedNames += ","; + joinedNames += Arrays + .stream(clusterNames) + .map(s -> "search.remote." + s + ".skip_unavailable") + .sorted() + .collect(Collectors.joining(",")); + joinedNames += ",search.remote.connections_per_cluster,search.remote.initial_connect_timeout,search.remote.connect"; + + assertThat(issue, equalTo(new DeprecationIssue( + DeprecationIssue.Level.CRITICAL, + String.format( + Locale.ROOT, + "search.remote settings [%s] are deprecated and will be removed in the next major version", + joinedNames + ), + expectedUrl, + String.format( + Locale.ROOT, + "replace search.remote settings [%s] with their secure 'cluster.remote' replacements", + joinedNames + ), false, null))); + + // test for absence of deprecated exporter passwords + issue = NodeDeprecationChecks.checkMonitoringExporterPassword(Settings.builder().build(), null, null, licenseState); + assertThat(issue, nullValue()); + } + public void testClusterRoutingAllocationIncludeRelocationsSetting() { boolean settingValue = randomBoolean(); String settingKey = CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey();