Skip to content

adding a deprecation info check for search.remote properties #76954

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -94,6 +94,7 @@ private DeprecationChecks() {
NodeDeprecationChecks::checkSharedDataPathSetting,
NodeDeprecationChecks::checkSingleDataNodeWatermarkSetting,
NodeDeprecationChecks::checkImplicitlyDisabledSecurityOnBasicAndTrial,
NodeDeprecationChecks::checkSearchRemoteSettings,
NodeDeprecationChecks::checkMonitoringExporterPassword,
NodeDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Setting<?>> 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/breaking-changes-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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/breaking-changes-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();
Expand Down