From 6e81d231481972ec64d3fddc8794d8b3ac75cc71 Mon Sep 17 00:00:00 2001 From: Andrew Ross Date: Wed, 29 Jan 2025 12:51:03 -0800 Subject: [PATCH] Remove deprecated 'reindex.remote.whitelist` setting (#17188) This has been replaced by `reindex.remote.allowlist`. Signed-off-by: Andrew Ross --- .../index/reindex/ReindexModulePlugin.java | 1 - .../index/reindex/TransportReindexAction.java | 11 +-- .../reindex/ReindexRenamedSettingTests.java | 85 ------------------- 3 files changed, 1 insertion(+), 96 deletions(-) delete mode 100644 modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/ReindexModulePlugin.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/ReindexModulePlugin.java index aa48da4cb2421..783b011b99249 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/ReindexModulePlugin.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/ReindexModulePlugin.java @@ -130,7 +130,6 @@ public Collection createComponents( @Override public List> getSettings() { final List> settings = new ArrayList<>(); - settings.add(TransportReindexAction.REMOTE_CLUSTER_WHITELIST); settings.add(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST); settings.add(TransportReindexAction.REMOTE_REINDEX_RETRY_INITIAL_BACKOFF); settings.add(TransportReindexAction.REMOTE_REINDEX_RETRY_MAX_COUNT); diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java index c9a970a4118b3..87ef85a5ca2a0 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportReindexAction.java @@ -57,18 +57,9 @@ import static java.util.Collections.emptyList; public class TransportReindexAction extends HandledTransportAction { - static final Setting> REMOTE_CLUSTER_WHITELIST = Setting.listSetting( - "reindex.remote.whitelist", - emptyList(), - Function.identity(), - Property.NodeScope, - Property.Deprecated - ); - // The setting below is going to replace the above. - // To keep backwards compatibility, the old usage is remained, and it's also used as the fallback for the new usage. public static final Setting> REMOTE_CLUSTER_ALLOWLIST = Setting.listSetting( "reindex.remote.allowlist", - REMOTE_CLUSTER_WHITELIST, + emptyList(), Function.identity(), Property.NodeScope ); diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java deleted file mode 100644 index be4bacce9b57c..0000000000000 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java +++ /dev/null @@ -1,85 +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. - */ - -package org.opensearch.index.reindex; - -import org.opensearch.common.settings.Setting; -import org.opensearch.common.settings.Settings; -import org.opensearch.test.OpenSearchTestCase; - -import java.util.Arrays; -import java.util.List; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.hasItems; - -/** - * A unit test to validate the former name of the setting 'reindex.remote.allowlist' still take effect, - * after it is deprecated, so that the backwards compatibility is maintained. - * The test can be removed along with removing support of the deprecated setting. - */ -public class ReindexRenamedSettingTests extends OpenSearchTestCase { - private final ReindexModulePlugin plugin = new ReindexModulePlugin(); - - /** - * Validate the both settings are known and supported. - */ - public void testReindexSettingsExist() { - List> settings = plugin.getSettings(); - assertThat( - "Both 'reindex.remote.allowlist' and its predecessor should be supported settings of Reindex plugin", - settings, - hasItems(TransportReindexAction.REMOTE_CLUSTER_WHITELIST, TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST) - ); - } - - /** - * Validate the default value of the both settings is the same. - */ - public void testSettingFallback() { - assertThat( - TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(Settings.EMPTY), - equalTo(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(Settings.EMPTY)) - ); - } - - /** - * Validate the new setting can be configured correctly, and it doesn't impact the old setting. - */ - public void testSettingGetValue() { - Settings settings = Settings.builder().put("reindex.remote.allowlist", "127.0.0.1:*").build(); - assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*"))); - assertThat( - TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), - equalTo(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getDefault(Settings.EMPTY)) - ); - } - - /** - * Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. - */ - public void testSettingGetValueWithFallback() { - Settings settings = Settings.builder().put("reindex.remote.whitelist", "127.0.0.1:*").build(); - assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*"))); - assertSettingDeprecationsAndWarnings(new Setting[] { TransportReindexAction.REMOTE_CLUSTER_WHITELIST }); - } - - /** - * Validate the value of the old setting will be ignored, if the new setting is configured. - */ - public void testSettingGetValueWhenBothAreConfigured() { - Settings settings = Settings.builder() - .put("reindex.remote.allowlist", "127.0.0.1:*") - .put("reindex.remote.whitelist", "[::1]:*, 127.0.0.1:*") - .build(); - assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*"))); - assertThat(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), equalTo(Arrays.asList("[::1]:*", "127.0.0.1:*"))); - assertSettingDeprecationsAndWarnings(new Setting[] { TransportReindexAction.REMOTE_CLUSTER_WHITELIST }); - } - -}