diff --git a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java index 77bd7e443f7f7..3c6232569f3f1 100644 --- a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java @@ -39,7 +39,6 @@ import org.opensearch.client.Response; import org.opensearch.client.ResponseException; import org.opensearch.client.RestClient; -import org.opensearch.client.WarningFailureException; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.metadata.MetadataIndexStateService; import org.opensearch.common.Booleans; @@ -1110,13 +1109,9 @@ private void checkSnapshot(final String snapshotName, final int count, final Ver assertEquals(singletonList(tookOnVersion.toString()), XContentMapValues.extractValue("snapshots.version", listSnapshotResponse)); // Remove the routing setting and template so we can test restoring them. - try { - Request clearRoutingFromSettings = new Request("PUT", "/_cluster/settings"); - clearRoutingFromSettings.setJsonEntity("{\"persistent\":{\"cluster.routing.allocation.exclude.test_attr\": null}}"); - client().performRequest(clearRoutingFromSettings); - } catch (WarningFailureException e) { - throw e; - } + Request clearRoutingFromSettings = new Request("PUT", "/_cluster/settings"); + clearRoutingFromSettings.setJsonEntity("{\"persistent\":{\"cluster.routing.allocation.exclude.test_attr\": null}}"); + client().performRequest(clearRoutingFromSettings); client().performRequest(new Request("DELETE", "/_template/test_template")); // Restore diff --git a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartSettingsUpgradeIT.java b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartSettingsUpgradeIT.java deleted file mode 100644 index f82380fa672e4..0000000000000 --- a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartSettingsUpgradeIT.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.upgrades; - -import org.opensearch.LegacyESVersion; -import org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse; -import org.opensearch.client.Request; -import org.opensearch.client.Response; -import org.opensearch.common.Strings; -import org.opensearch.common.settings.Setting; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.xcontent.XContentBuilder; -import org.opensearch.common.xcontent.XContentParser; -import org.opensearch.common.xcontent.json.JsonXContent; -import org.opensearch.transport.RemoteClusterService; -import org.opensearch.transport.SniffConnectionStrategy; - -import java.io.IOException; -import java.util.Collections; - -import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.opensearch.transport.RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE; -import static org.opensearch.transport.SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_SEEDS; -import static org.opensearch.transport.SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY; -import static org.opensearch.transport.SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY; -import static org.hamcrest.Matchers.equalTo; - -public class FullClusterRestartSettingsUpgradeIT extends AbstractFullClusterRestartTestCase { - - public void testRemoteClusterSettingsUpgraded() throws IOException { - assumeTrue("settings automatically upgraded since 6.5.0", getOldClusterVersion().before(LegacyESVersion.fromString("6.5.0"))); - if (isRunningAgainstOldCluster()) { - final Request putSettingsRequest = new Request("PUT", "/_cluster/settings"); - try (XContentBuilder builder = jsonBuilder()) { - builder.startObject(); - { - builder.startObject("persistent"); - { - builder.field("search.remote.foo.skip_unavailable", true); - builder.field("search.remote.foo.seeds", Collections.singletonList("localhost:9200")); - builder.field("search.remote.foo.proxy", "localhost:9200"); - } - builder.endObject(); - } - builder.endObject(); - putSettingsRequest.setJsonEntity(Strings.toString(builder)); - } - client().performRequest(putSettingsRequest); - - final Request getSettingsRequest = new Request("GET", "/_cluster/settings"); - final Response response = client().performRequest(getSettingsRequest); - try (XContentParser parser = createParser(JsonXContent.jsonXContent, response.getEntity().getContent())) { - final ClusterGetSettingsResponse clusterGetSettingsResponse = ClusterGetSettingsResponse.fromXContent(parser); - final Settings settings = clusterGetSettingsResponse.getPersistentSettings(); - - assertTrue(SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").exists(settings)); - assertTrue(SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").get(settings)); - assertTrue(SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace("foo").exists(settings)); - assertThat( - SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace("foo").get(settings), - equalTo(Collections.singletonList("localhost:9200"))); - assertTrue(SEARCH_REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace("foo").exists(settings)); - assertEquals(String.valueOf(SEARCH_REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace("foo").get(settings)), - "localhost:9200"); - } - - assertSettingDeprecationsAndWarnings(new Setting[]{ - SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo"), - SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace("foo"), - SEARCH_REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace("foo")}); - } else { - final Request getSettingsRequest = new Request("GET", "/_cluster/settings"); - final Response getSettingsResponse = client().performRequest(getSettingsRequest); - try (XContentParser parser = createParser(JsonXContent.jsonXContent, getSettingsResponse.getEntity().getContent())) { - final ClusterGetSettingsResponse clusterGetSettingsResponse = ClusterGetSettingsResponse.fromXContent(parser); - final Settings settings = clusterGetSettingsResponse.getPersistentSettings(); - - assertFalse(SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").exists(settings)); - assertTrue( - settings.toString(), - RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").exists(settings)); - assertTrue(RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").get(settings)); - assertFalse(SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace("foo").exists(settings)); - assertTrue(SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace("foo").exists(settings)); - assertThat( - SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace("foo").get(settings), - equalTo(Collections.singletonList("localhost:9200"))); - assertFalse(SEARCH_REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace("foo").exists(settings)); - assertTrue(REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace("foo").exists(settings)); - assertEquals(String.valueOf(REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace("foo").get(settings)), - "localhost:9200"); - } - } - } - -} diff --git a/server/src/internalClusterTest/java/org/opensearch/common/settings/UpgradeSettingsIT.java b/server/src/internalClusterTest/java/org/opensearch/common/settings/UpgradeSettingsIT.java index bef43d734854f..3c8f914ba4f2f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/common/settings/UpgradeSettingsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/common/settings/UpgradeSettingsIT.java @@ -37,8 +37,6 @@ import org.opensearch.cluster.metadata.Metadata; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchSingleNodeTestCase; -import org.opensearch.transport.RemoteClusterService; -import org.opensearch.transport.SniffConnectionStrategy; import org.junit.After; @@ -127,42 +125,4 @@ private void runUpgradeSettingsOnUpdateTest( assertTrue(UpgradeSettingsPlugin.newSetting.exists(settingsFunction.apply(response.getState().metadata()))); assertThat(UpgradeSettingsPlugin.newSetting.get(settingsFunction.apply(response.getState().metadata())), equalTo("new." + value)); } - - public void testUpgradeRemoteClusterSettings() { - final boolean skipUnavailable = randomBoolean(); - client().admin() - .cluster() - .prepareUpdateSettings() - .setPersistentSettings( - Settings.builder() - .put("search.remote.foo.skip_unavailable", skipUnavailable) - .putList("search.remote.foo.seeds", Collections.singletonList("localhost:9200")) - .put("search.remote.foo.proxy", "localhost:9200") - .build() - ) - .get(); - - final ClusterStateResponse response = client().admin().cluster().prepareState().clear().setMetadata(true).get(); - - final Settings settings = response.getState().metadata().persistentSettings(); - assertFalse(RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").exists(settings)); - assertTrue(RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").exists(settings)); - assertThat( - RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").get(settings), - equalTo(skipUnavailable) - ); - assertFalse(SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace("foo").exists(settings)); - assertTrue(SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace("foo").exists(settings)); - assertThat( - SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace("foo").get(settings), - equalTo(Collections.singletonList("localhost:9200")) - ); - assertFalse(SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace("foo").exists(settings)); - assertTrue(SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace("foo").exists(settings)); - assertThat( - SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace("foo").get(settings), - equalTo("localhost:9200") - ); - } - } diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index 7a8c54cc2794b..f1187f3344c83 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -339,23 +339,16 @@ public void apply(Settings value, Settings current, Settings previous) { TransportSearchAction.SHARD_COUNT_LIMIT_SETTING, TransportSearchAction.SEARCH_CANCEL_AFTER_TIME_INTERVAL_SETTING, RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE, - RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE, SniffConnectionStrategy.REMOTE_CONNECTIONS_PER_CLUSTER, RemoteClusterService.REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING, - RemoteClusterService.SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING, RemoteClusterService.REMOTE_NODE_ATTRIBUTE, - RemoteClusterService.SEARCH_REMOTE_NODE_ATTRIBUTE, RemoteClusterService.ENABLE_REMOTE_CLUSTERS, - RemoteClusterService.SEARCH_ENABLE_REMOTE_CLUSTERS, RemoteClusterService.REMOTE_CLUSTER_PING_SCHEDULE, RemoteClusterService.REMOTE_CLUSTER_COMPRESS, RemoteConnectionStrategy.REMOTE_CONNECTION_MODE, ProxyConnectionStrategy.PROXY_ADDRESS, ProxyConnectionStrategy.REMOTE_SOCKET_CONNECTIONS, ProxyConnectionStrategy.SERVER_NAME, - SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_SEEDS, - SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY, - SniffConnectionStrategy.SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER, ProxyConnectionStrategy.SERVER_NAME, SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY, SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS, @@ -577,12 +570,6 @@ public void apply(Settings value, Settings current, Settings previous) { ) ); - public static List> BUILT_IN_SETTING_UPGRADERS = Collections.unmodifiableList( - Arrays.asList( - SniffConnectionStrategy.SEARCH_REMOTE_CLUSTER_SEEDS_UPGRADER, - SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY_UPGRADER, - RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE_UPGRADER - ) - ); + public static List> BUILT_IN_SETTING_UPGRADERS = Collections.emptyList(); } diff --git a/server/src/main/java/org/opensearch/transport/RemoteClusterAware.java b/server/src/main/java/org/opensearch/transport/RemoteClusterAware.java index a08019ebbe4b9..d8641bc6f536d 100644 --- a/server/src/main/java/org/opensearch/transport/RemoteClusterAware.java +++ b/server/src/main/java/org/opensearch/transport/RemoteClusterAware.java @@ -144,8 +144,6 @@ public void listenForUpdates(ClusterSettings clusterSettings) { RemoteClusterService.REMOTE_CLUSTER_COMPRESS, RemoteClusterService.REMOTE_CLUSTER_PING_SCHEDULE, RemoteConnectionStrategy.REMOTE_CONNECTION_MODE, - SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_SEEDS, - SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY, SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY, SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS, SniffConnectionStrategy.REMOTE_NODE_CONNECTIONS, diff --git a/server/src/main/java/org/opensearch/transport/RemoteClusterService.java b/server/src/main/java/org/opensearch/transport/RemoteClusterService.java index a8b89913d34c4..8791a322b2c59 100644 --- a/server/src/main/java/org/opensearch/transport/RemoteClusterService.java +++ b/server/src/main/java/org/opensearch/transport/RemoteClusterService.java @@ -34,7 +34,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.Version; import org.opensearch.action.ActionListener; import org.opensearch.action.OriginalIndices; import org.opensearch.action.support.GroupedActionListener; @@ -46,7 +45,6 @@ import org.opensearch.common.Strings; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Setting; -import org.opensearch.common.settings.SettingUpgrader; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.ConcurrentCollections; @@ -81,52 +79,26 @@ public final class RemoteClusterService extends RemoteClusterAware implements Cl private final Logger logger = LogManager.getLogger(RemoteClusterService.class); - static { - // remove search.remote.* settings in 8.0.0 - assert Version.CURRENT.major < 8; - } - - public static final Setting SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING = Setting.positiveTimeSetting( - "search.remote.initial_connect_timeout", - TimeValue.timeValueSeconds(30), - Setting.Property.NodeScope, - Setting.Property.Deprecated - ); - /** * The initial connect timeout for remote cluster connections */ public static final Setting REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING = Setting.positiveTimeSetting( "cluster.remote.initial_connect_timeout", - SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING, // the default needs to be thirty seconds when fallback is removed + TimeValue.timeValueSeconds(30), Setting.Property.NodeScope ); - public static final Setting SEARCH_REMOTE_NODE_ATTRIBUTE = Setting.simpleString( - "search.remote.node.attr", - Setting.Property.NodeScope, - Setting.Property.Deprecated - ); - /** * The name of a node attribute to select nodes that should be connected to in the remote cluster. * For instance a node can be configured with {@code node.attr.gateway: true} in order to be eligible as a gateway node between - * clusters. In that case {@code search.remote.node.attr: gateway} can be used to filter out other nodes in the remote cluster. + * clusters. In that case {@code cluster.remote.node.attr: gateway} can be used to filter out other nodes in the remote cluster. * The value of the setting is expected to be a boolean, {@code true} for nodes that can become gateways, {@code false} otherwise. */ public static final Setting REMOTE_NODE_ATTRIBUTE = Setting.simpleString( "cluster.remote.node.attr", - SEARCH_REMOTE_NODE_ATTRIBUTE, // no default is needed when fallback is removed, use simple string which gives empty Setting.Property.NodeScope ); - public static final Setting SEARCH_ENABLE_REMOTE_CLUSTERS = Setting.boolSetting( - "search.remote.connect", - true, - Setting.Property.NodeScope, - Setting.Property.Deprecated - ); - /** * If true connecting to remote clusters is supported on this node. If false this node will not establish * connections to any remote clusters configured. Search requests executed against this node (where this node is the coordinating node) @@ -134,44 +106,15 @@ public final class RemoteClusterService extends RemoteClusterAware implements Cl */ public static final Setting ENABLE_REMOTE_CLUSTERS = Setting.boolSetting( "cluster.remote.connect", - SEARCH_ENABLE_REMOTE_CLUSTERS, // the default needs to be true when fallback is removed + true, Setting.Property.Deprecated, Setting.Property.NodeScope ); - public static final Setting.AffixSetting SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE = Setting.affixKeySetting( - "search.remote.", - "skip_unavailable", - key -> boolSetting(key, false, Setting.Property.Deprecated, Setting.Property.Dynamic, Setting.Property.NodeScope) - ); - - public static final SettingUpgrader SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE_UPGRADER = new SettingUpgrader() { - - @Override - public Setting getSetting() { - return SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE; - } - - @Override - public String getKey(final String key) { - return key.replaceFirst("^search", "cluster"); - } - - }; - public static final Setting.AffixSetting REMOTE_CLUSTER_SKIP_UNAVAILABLE = Setting.affixKeySetting( "cluster.remote.", "skip_unavailable", - (ns, key) -> boolSetting( - key, - // the default needs to be false when fallback is removed - "_na_".equals(key) - ? SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace(key) - : SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSetting(key.replaceAll("^cluster", "search")), - new RemoteConnectionEnabled<>(ns, key), - Setting.Property.Dynamic, - Setting.Property.NodeScope - ) + (ns, key) -> boolSetting(key, false, new RemoteConnectionEnabled<>(ns, key), Setting.Property.Dynamic, Setting.Property.NodeScope) ); public static final Setting.AffixSetting REMOTE_CLUSTER_PING_SCHEDULE = Setting.affixKeySetting( @@ -308,7 +251,6 @@ Set getRemoteClusterNames() { public void listenForUpdates(ClusterSettings clusterSettings) { super.listenForUpdates(clusterSettings); clusterSettings.addAffixUpdateConsumer(REMOTE_CLUSTER_SKIP_UNAVAILABLE, this::updateSkipUnavailable, (alias, value) -> {}); - clusterSettings.addAffixUpdateConsumer(SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE, this::updateSkipUnavailable, (alias, value) -> {}); } private synchronized void updateSkipUnavailable(String clusterAlias, Boolean skipUnavailable) { diff --git a/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java b/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java index 34591f8a3dfc1..5d2b2d3ac684f 100644 --- a/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java +++ b/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java @@ -50,7 +50,6 @@ import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; import org.opensearch.common.settings.Setting; -import org.opensearch.common.settings.SettingUpgrader; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; import org.opensearch.common.util.concurrent.ThreadContext; @@ -77,65 +76,17 @@ public class SniffConnectionStrategy extends RemoteConnectionStrategy { - static { - // remove search.remote.* settings in 8.0.0 - assert Version.CURRENT.major < 8; - } - - public static final Setting.AffixSetting> SEARCH_REMOTE_CLUSTERS_SEEDS = Setting.affixKeySetting( - "search.remote.", - "seeds", - key -> Setting.listSetting(key, Collections.emptyList(), s -> { - parsePort(s); - return s; - }, Setting.Property.Deprecated, Setting.Property.Dynamic, Setting.Property.NodeScope) - ); - - public static final SettingUpgrader> SEARCH_REMOTE_CLUSTER_SEEDS_UPGRADER = new SettingUpgrader>() { - - @Override - public Setting> getSetting() { - return SEARCH_REMOTE_CLUSTERS_SEEDS; - } - - @Override - public String getKey(final String key) { - return key.replaceFirst("^search", "cluster"); - } - - }; - /** * A list of initial seed nodes to discover eligible nodes from the remote cluster */ public static final Setting.AffixSetting> REMOTE_CLUSTER_SEEDS = Setting.affixKeySetting( "cluster.remote.", "seeds", - (ns, key) -> Setting.listSetting( - key, - // the default needs to be emptyList() when fallback is removed - SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace(ns), - s -> { - // validate seed address - parsePort(s); - return s; - }, - s -> SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace(ns).get(s), - new StrategyValidator<>(ns, key, ConnectionStrategy.SNIFF), - Setting.Property.Dynamic, - Setting.Property.NodeScope - ) - ); - - public static final Setting.AffixSetting SEARCH_REMOTE_CLUSTERS_PROXY = Setting.affixKeySetting( - "search.remote.", - "proxy", - key -> Setting.simpleString(key, s -> { - if (Strings.hasLength(s)) { - parsePort(s); - } - }, Setting.Property.Deprecated, Setting.Property.Dynamic, Setting.Property.NodeScope), - () -> REMOTE_CLUSTER_SEEDS + (ns, key) -> Setting.listSetting(key, Collections.emptyList(), s -> { + // validate seed address + parsePort(s); + return s; + }, new StrategyValidator<>(ns, key, ConnectionStrategy.SNIFF), Setting.Property.Dynamic, Setting.Property.NodeScope) ); /** @@ -151,25 +102,17 @@ public String getKey(final String key) { if (Strings.hasLength(s)) { parsePort(s); } - }), SEARCH_REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace(ns), Setting.Property.Dynamic, Setting.Property.NodeScope), + }), Setting.Property.Dynamic, Setting.Property.NodeScope), () -> REMOTE_CLUSTER_SEEDS ); - public static final Setting SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER = intSetting( - "search.remote.connections_per_cluster", - 3, - 1, - Setting.Property.NodeScope, - Setting.Property.Deprecated - ); - /** * The maximum number of connections that will be established to a remote cluster. For instance if there is only a single * seed node, other nodes will be discovered up to the given number of nodes in this setting. The default is 3. */ public static final Setting REMOTE_CONNECTIONS_PER_CLUSTER = intSetting( "cluster.remote.connections_per_cluster", - SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER, // the default needs to three when fallback is removed, + 3, 1, Setting.Property.NodeScope ); @@ -190,20 +133,6 @@ public String getKey(final String key) { ) ); - public static final SettingUpgrader SEARCH_REMOTE_CLUSTERS_PROXY_UPGRADER = new SettingUpgrader() { - - @Override - public Setting getSetting() { - return SEARCH_REMOTE_CLUSTERS_PROXY; - } - - @Override - public String getKey(final String key) { - return key.replaceFirst("^search", "cluster"); - } - - }; - static final int CHANNELS_PER_CONNECTION = 6; private static final Predicate DEFAULT_NODE_PREDICATE = (node) -> Version.CURRENT.isCompatible(node.getVersion()) diff --git a/server/src/test/java/org/opensearch/transport/RemoteClusterSettingsTests.java b/server/src/test/java/org/opensearch/transport/RemoteClusterSettingsTests.java index dede145e11b50..a07883b79dc9b 100644 --- a/server/src/test/java/org/opensearch/transport/RemoteClusterSettingsTests.java +++ b/server/src/test/java/org/opensearch/transport/RemoteClusterSettingsTests.java @@ -40,8 +40,6 @@ import org.opensearch.node.NodeRoleSettings; import org.opensearch.test.OpenSearchTestCase; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.TimeUnit; import static org.opensearch.test.NodeRoles.nonRemoteClusterClientNode; @@ -50,16 +48,9 @@ import static org.opensearch.transport.RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE; import static org.opensearch.transport.RemoteClusterService.REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING; import static org.opensearch.transport.RemoteClusterService.REMOTE_NODE_ATTRIBUTE; -import static org.opensearch.transport.RemoteClusterService.SEARCH_ENABLE_REMOTE_CLUSTERS; -import static org.opensearch.transport.RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE; -import static org.opensearch.transport.RemoteClusterService.SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING; -import static org.opensearch.transport.RemoteClusterService.SEARCH_REMOTE_NODE_ATTRIBUTE; import static org.opensearch.transport.SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY; import static org.opensearch.transport.SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS; import static org.opensearch.transport.SniffConnectionStrategy.REMOTE_CONNECTIONS_PER_CLUSTER; -import static org.opensearch.transport.SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY; -import static org.opensearch.transport.SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_SEEDS; -import static org.opensearch.transport.SniffConnectionStrategy.SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER; import static org.hamcrest.Matchers.emptyCollectionOf; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; @@ -67,49 +58,18 @@ public class RemoteClusterSettingsTests extends OpenSearchTestCase { - public void testConnectionsPerClusterFallback() { - final int value = randomIntBetween(1, 8); - final Settings settings = Settings.builder().put(SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER.getKey(), value).build(); - assertThat(REMOTE_CONNECTIONS_PER_CLUSTER.get(settings), equalTo(value)); - assertSettingDeprecationsAndWarnings(new Setting[] { SEARCH_REMOTE_CONNECTIONS_PER_CLUSTER }); - } - public void testConnectionsPerClusterDefault() { assertThat(REMOTE_CONNECTIONS_PER_CLUSTER.get(Settings.EMPTY), equalTo(3)); } - public void testInitialConnectTimeoutFallback() { - final String value = randomTimeValue(30, 300, "s"); - final Settings settings = Settings.builder().put(SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.getKey(), value).build(); - assertThat( - REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.get(settings), - equalTo(TimeValue.parseTimeValue(value, SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.getKey())) - ); - assertSettingDeprecationsAndWarnings(new Setting[] { SEARCH_REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING }); - } - public void testInitialConnectTimeoutDefault() { assertThat(REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.get(Settings.EMPTY), equalTo(new TimeValue(30, TimeUnit.SECONDS))); } - public void testRemoteNodeAttributeFallback() { - final String attribute = randomAlphaOfLength(8); - final Settings settings = Settings.builder().put(SEARCH_REMOTE_NODE_ATTRIBUTE.getKey(), attribute).build(); - assertThat(REMOTE_NODE_ATTRIBUTE.get(settings), equalTo(attribute)); - assertSettingDeprecationsAndWarnings(new Setting[] { SEARCH_REMOTE_NODE_ATTRIBUTE }); - } - public void testRemoteNodeAttributeDefault() { assertThat(REMOTE_NODE_ATTRIBUTE.get(Settings.EMPTY), equalTo("")); } - public void testEnableRemoteClustersFallback() { - final boolean enable = randomBoolean(); - final Settings settings = Settings.builder().put(SEARCH_ENABLE_REMOTE_CLUSTERS.getKey(), enable).build(); - assertThat(ENABLE_REMOTE_CLUSTERS.get(settings), equalTo(enable)); - assertSettingDeprecationsAndWarnings(new Setting[] { SEARCH_ENABLE_REMOTE_CLUSTERS }); - } - public void testRemoteClusterClientDefault() { assertTrue(DiscoveryNode.isRemoteClusterClient(Settings.EMPTY)); assertThat(NodeRoleSettings.NODE_ROLES_SETTING.get(Settings.EMPTY), hasItem(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)); @@ -132,59 +92,16 @@ public void testDisableEnableRemoteClusters() { assertSettingDeprecationsAndWarnings(new Setting[] { ENABLE_REMOTE_CLUSTERS }); } - public void testDisableSearchEnableRemoteClusters() { - assertFalse(DiscoveryNode.isRemoteClusterClient(Settings.builder().put(SEARCH_ENABLE_REMOTE_CLUSTERS.getKey(), false).build())); - assertSettingDeprecationsAndWarnings(new Setting[] { SEARCH_ENABLE_REMOTE_CLUSTERS }); - } - - public void testSkipUnavailableFallback() { - final String alias = randomAlphaOfLength(8); - final boolean skip = randomBoolean(); - final Settings settings = Settings.builder() - .put(SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace(alias).getKey(), skip) - .build(); - assertThat(REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace(alias).get(settings), equalTo(skip)); - assertSettingDeprecationsAndWarnings( - new Setting[] { SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace(alias) } - ); - } - public void testSkipUnavailableDefault() { final String alias = randomAlphaOfLength(8); assertFalse(REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace(alias).get(Settings.EMPTY)); } - public void testSeedsFallback() { - final String alias = randomAlphaOfLength(8); - final int numberOfSeeds = randomIntBetween(1, 8); - final List seeds = new ArrayList<>(numberOfSeeds); - for (int i = 0; i < numberOfSeeds; i++) { - seeds.add("localhost:" + Integer.toString(9200 + i)); - } - final Settings settings = Settings.builder() - .put(SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace(alias).getKey(), String.join(",", seeds)) - .build(); - assertThat(REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace(alias).get(settings), equalTo(seeds)); - assertSettingDeprecationsAndWarnings(new Setting[] { SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace(alias) }); - } - public void testSeedsDefault() { final String alias = randomAlphaOfLength(8); assertThat(REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace(alias).get(Settings.EMPTY), emptyCollectionOf(String.class)); } - public void testProxyFallback() { - final String alias = randomAlphaOfLength(8); - final String proxy = randomAlphaOfLength(8); - final int port = randomIntBetween(9200, 9300); - final String value = proxy + ":" + port; - final Settings settings = Settings.builder() - .put(SEARCH_REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace(alias).getKey(), value) - .build(); - assertThat(REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace(alias).get(settings), equalTo(value)); - assertSettingDeprecationsAndWarnings(new Setting[] { SEARCH_REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace(alias) }); - } - public void testProxyDefault() { final String alias = randomAlphaOfLength(8); assertThat(REMOTE_CLUSTERS_PROXY.getConcreteSettingForNamespace(alias).get(Settings.EMPTY), equalTo(""));