diff --git a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt index 609f87330..e14aa8cf8 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt @@ -451,6 +451,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin LegacyOpenDistroManagedIndexSettings.HISTORY_NUMBER_OF_REPLICAS, LegacyOpenDistroManagedIndexSettings.POLICY_ID, LegacyOpenDistroManagedIndexSettings.ROLLOVER_ALIAS, + LegacyOpenDistroManagedIndexSettings.ROLLOVER_SKIP, LegacyOpenDistroManagedIndexSettings.INDEX_STATE_MANAGEMENT_ENABLED, LegacyOpenDistroManagedIndexSettings.METADATA_SERVICE_ENABLED, LegacyOpenDistroManagedIndexSettings.JOB_INTERVAL, @@ -462,6 +463,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin LegacyOpenDistroManagedIndexSettings.AUTO_MANAGE, LegacyOpenDistroManagedIndexSettings.METADATA_SERVICE_STATUS, LegacyOpenDistroManagedIndexSettings.TEMPLATE_MIGRATION_CONTROL, + LegacyOpenDistroManagedIndexSettings.RESTRICTED_INDEX_PATTERN, LegacyOpenDistroRollupSettings.ROLLUP_INGEST_BACKOFF_COUNT, LegacyOpenDistroRollupSettings.ROLLUP_INGEST_BACKOFF_MILLIS, LegacyOpenDistroRollupSettings.ROLLUP_SEARCH_BACKOFF_COUNT, diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/opensearchapi/OpenSearchExtensions.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/opensearchapi/OpenSearchExtensions.kt index 14106a78f..6ac3c97a0 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/opensearchapi/OpenSearchExtensions.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/opensearchapi/OpenSearchExtensions.kt @@ -55,6 +55,9 @@ fun IndexMetadata.getRolloverAlias(): String? { } fun IndexMetadata.getRolloverSkip(): Boolean { + if (this.settings.get(ManagedIndexSettings.ROLLOVER_SKIP.key).isNullOrBlank()) { + return this.settings.getAsBoolean(LegacyOpenDistroManagedIndexSettings.ROLLOVER_SKIP.key, false) + } return this.settings.getAsBoolean(ManagedIndexSettings.ROLLOVER_SKIP.key, false) } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/LegacyOpenDistroManagedIndexSettings.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/LegacyOpenDistroManagedIndexSettings.kt index ce65126f7..4d5499d36 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/LegacyOpenDistroManagedIndexSettings.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/LegacyOpenDistroManagedIndexSettings.kt @@ -75,6 +75,14 @@ class LegacyOpenDistroManagedIndexSettings { Setting.Property.Deprecated ) + val ROLLOVER_SKIP: Setting = Setting.boolSetting( + "index.opendistro.index_state_management.rollover_skip", + false, + Setting.Property.IndexScope, + Setting.Property.Dynamic, + Setting.Property.Deprecated + ) + val AUTO_MANAGE: Setting = Setting.boolSetting( "index.opendistro.index_state_management.auto_manage", true, @@ -191,5 +199,13 @@ class LegacyOpenDistroManagedIndexSettings { Setting.Property.Dynamic, Setting.Property.Deprecated ) + + val RESTRICTED_INDEX_PATTERN = Setting.simpleString( + "opendistro.index_state_management.restricted_index_pattern", + ManagedIndexSettings.DEFAULT_RESTRICTED_PATTERN, + Setting.Property.NodeScope, + Setting.Property.Dynamic, + Setting.Property.Deprecated + ) } } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/ManagedIndexSettings.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/ManagedIndexSettings.kt index f39e9e206..48ce1a218 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/ManagedIndexSettings.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/ManagedIndexSettings.kt @@ -74,7 +74,7 @@ class ManagedIndexSettings { val ROLLOVER_SKIP: Setting = Setting.boolSetting( "index.plugins.index_state_management.rollover_skip", - false, + LegacyOpenDistroManagedIndexSettings.ROLLOVER_SKIP, Setting.Property.IndexScope, Setting.Property.Dynamic ) @@ -194,7 +194,7 @@ class ManagedIndexSettings { val RESTRICTED_INDEX_PATTERN = Setting.simpleString( "plugins.index_state_management.restricted_index_pattern", - DEFAULT_RESTRICTED_PATTERN, + LegacyOpenDistroManagedIndexSettings.RESTRICTED_INDEX_PATTERN, Setting.Property.NodeScope, Setting.Property.Dynamic ) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/shrink/AttemptMoveShardsStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/shrink/AttemptMoveShardsStep.kt index cdd617653..8b1367768 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/shrink/AttemptMoveShardsStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/shrink/AttemptMoveShardsStep.kt @@ -44,7 +44,6 @@ import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ShrinkActio import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.indices.InvalidIndexNameException -import org.opensearch.jobscheduler.repackage.com.cronutils.utils.VisibleForTesting import org.opensearch.jobscheduler.spi.LockModel import org.opensearch.jobscheduler.spi.utils.LockService import org.opensearch.script.Script @@ -289,7 +288,6 @@ class AttemptMoveShardsStep(private val action: ShrinkAction) : Step(name) { /* * Returns the list of node names for nodes with enough space to shrink to, in increasing order of space available */ - @VisibleForTesting @SuppressWarnings("NestedBlockDepth", "ComplexMethod") private suspend fun findSuitableNodes( stepContext: StepContext, diff --git a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementSettingsTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementSettingsTests.kt index 0176c90a2..3e03a07b0 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementSettingsTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementSettingsTests.kt @@ -38,6 +38,7 @@ class IndexManagementSettingsTests : OpenSearchTestCase() { LegacyOpenDistroManagedIndexSettings.HISTORY_NUMBER_OF_REPLICAS, LegacyOpenDistroManagedIndexSettings.POLICY_ID, LegacyOpenDistroManagedIndexSettings.ROLLOVER_ALIAS, + LegacyOpenDistroManagedIndexSettings.ROLLOVER_SKIP, LegacyOpenDistroManagedIndexSettings.INDEX_STATE_MANAGEMENT_ENABLED, LegacyOpenDistroManagedIndexSettings.METADATA_SERVICE_ENABLED, LegacyOpenDistroManagedIndexSettings.JOB_INTERVAL, @@ -46,6 +47,7 @@ class IndexManagementSettingsTests : OpenSearchTestCase() { LegacyOpenDistroManagedIndexSettings.COORDINATOR_BACKOFF_MILLIS, LegacyOpenDistroManagedIndexSettings.ALLOW_LIST, LegacyOpenDistroManagedIndexSettings.SNAPSHOT_DENY_LIST, + LegacyOpenDistroManagedIndexSettings.RESTRICTED_INDEX_PATTERN, LegacyOpenDistroRollupSettings.ROLLUP_INGEST_BACKOFF_COUNT, LegacyOpenDistroRollupSettings.ROLLUP_INGEST_BACKOFF_MILLIS, LegacyOpenDistroRollupSettings.ROLLUP_SEARCH_BACKOFF_COUNT, @@ -110,6 +112,23 @@ class IndexManagementSettingsTests : OpenSearchTestCase() { assertEquals(LegacyOpenDistroManagedIndexSettings.JOB_INTERVAL.get(settings), 5) } + fun testIndexSettingLegacyFallback() { + var settings = Settings.builder() + .put("index.opendistro.index_state_management.rollover_skip", true) + .build() + assertEquals(ManagedIndexSettings.ROLLOVER_SKIP.get(settings), true) + + settings = Settings.builder() + .put("index.opendistro.index_state_management.rollover_skip", true) + .put("index.plugins.index_state_management.rollover_skip", false) + .build() + assertEquals(ManagedIndexSettings.ROLLOVER_SKIP.get(settings), false) + + assertSettingDeprecationsAndWarnings( + arrayOf(LegacyOpenDistroManagedIndexSettings.ROLLOVER_SKIP) + ) + } + fun testSettingsGetValueWithLegacyFallback() { val settings = Settings.builder() .put("opendistro.index_state_management.enabled", false) @@ -127,6 +146,7 @@ class IndexManagementSettingsTests : OpenSearchTestCase() { .put("opendistro.index_state_management.history.number_of_replicas", 2) .putList("opendistro.index_state_management.allow_list", listOf("1")) .putList("opendistro.index_state_management.snapshot.deny_list", listOf("1")) + .put("opendistro.index_state_management.restricted_index_pattern", "blocked_index_pattern") .put("opendistro.rollup.enabled", false) .put("opendistro.rollup.search.enabled", false) .put("opendistro.rollup.ingest.backoff_millis", "1ms") @@ -151,6 +171,7 @@ class IndexManagementSettingsTests : OpenSearchTestCase() { assertEquals(ManagedIndexSettings.HISTORY_NUMBER_OF_REPLICAS.get(settings), 2) assertEquals(ManagedIndexSettings.ALLOW_LIST.get(settings), listOf("1")) assertEquals(ManagedIndexSettings.SNAPSHOT_DENY_LIST.get(settings), listOf("1")) + assertEquals(ManagedIndexSettings.RESTRICTED_INDEX_PATTERN.get(settings), "blocked_index_pattern") assertEquals(RollupSettings.ROLLUP_ENABLED.get(settings), false) assertEquals(RollupSettings.ROLLUP_SEARCH_ENABLED.get(settings), false) assertEquals(RollupSettings.ROLLUP_SEARCH_ALL_JOBS.get(settings), false) @@ -177,6 +198,7 @@ class IndexManagementSettingsTests : OpenSearchTestCase() { LegacyOpenDistroManagedIndexSettings.HISTORY_NUMBER_OF_REPLICAS, LegacyOpenDistroManagedIndexSettings.ALLOW_LIST, LegacyOpenDistroManagedIndexSettings.SNAPSHOT_DENY_LIST, + LegacyOpenDistroManagedIndexSettings.RESTRICTED_INDEX_PATTERN, LegacyOpenDistroRollupSettings.ROLLUP_ENABLED, LegacyOpenDistroRollupSettings.ROLLUP_SEARCH_ENABLED, LegacyOpenDistroRollupSettings.ROLLUP_INGEST_BACKOFF_MILLIS,