diff --git a/server/src/internalClusterTest/java/org/opensearch/remotemigration/ResizeIndexMigrationTestCase.java b/server/src/internalClusterTest/java/org/opensearch/remotemigration/ResizeIndexMigrationTestCase.java index 90e570a7367ae..fb64254ca8f85 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotemigration/ResizeIndexMigrationTestCase.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotemigration/ResizeIndexMigrationTestCase.java @@ -32,6 +32,10 @@ public class ResizeIndexMigrationTestCase extends MigrationBaseTestCase { private final static String STRICT_MODE = "strict"; private final static String MIXED_MODE = "mixed"; + /* + * This test will verify the resize request failure, when cluster mode is mixed + * and index is on DocRep node, and migration to remote store is in progress. + * */ public void testFailResizeIndexWhileDocRepToRemoteStoreMigration() throws Exception { internalCluster().setBootstrapClusterManagerNodeIndex(0); @@ -120,6 +124,10 @@ public void testFailResizeIndexWhileDocRepToRemoteStoreMigration() throws Except ); } + /* + * This test will verify the resize request failure, when cluster mode is mixed + * and index is on Remote Store node, and migration to DocRep node is in progress. + * */ public void testFailResizeIndexWhileRemoteStoreToDocRepMigration() throws Exception { addRemote = true; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java index 4faeceac4df8a..360bb2602efb0 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java @@ -374,6 +374,18 @@ protected String getClusterManagerActionName(DiscoveryNode node) { return super.getClusterManagerActionName(node); } + /** + * Reject resize request if cluster mode is [Mixed] and migration direction is [RemoteStore] and index is not on + * REMOTE_STORE_ENABLED node or [DocRep] and index is on REMOTE_STORE_ENABLED node. + * @param type resize type + * @param sourceIndexMetadata source index's metadata + * @param clusterSettings cluster settings + * @throws IllegalStateException if cluster mode is [Mixed] and migration direction is [RemoteStore] or [DocRep] and + * index's SETTING_REMOTE_STORE_ENABLED is not equal to the migration direction's value. + * For example, if migration direction is [RemoteStore] and index's SETTING_REMOTE_STORE_ENABLED + * is false, then throw IllegalStateException. If migration direction is [DocRep] and + * index's SETTING_REMOTE_STORE_ENABLED is true, then throw IllegalStateException. + */ private static void validateClusterModeSettings( final ResizeType type, IndexMetadata sourceIndexMetadata,