diff --git a/.github/workflows/multi-node-test-workflow.yml b/.github/workflows/multi-node-test-workflow.yml index 5937571b6..faa65cdaa 100644 --- a/.github/workflows/multi-node-test-workflow.yml +++ b/.github/workflows/multi-node-test-workflow.yml @@ -36,7 +36,7 @@ jobs: with: repository: 'opensearch-project/common-utils' path: common-utils - ref: 'main' + ref: '1.0' - name: Build common-utils working-directory: ./common-utils run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0 @@ -46,7 +46,7 @@ jobs: with: repository: 'opensearch-project/job-scheduler' path: job-scheduler - ref: 'main' + ref: '1.0' - name: Build job-scheduler working-directory: ./job-scheduler run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0 -Dbuild.snapshot=false diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml index 41201c466..369ad82d7 100644 --- a/.github/workflows/test-and-build-workflow.yml +++ b/.github/workflows/test-and-build-workflow.yml @@ -36,7 +36,7 @@ jobs: with: repository: 'opensearch-project/common-utils' path: common-utils - ref: 'main' + ref: '1.0' - name: Build common-utils working-directory: ./common-utils run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0 @@ -46,7 +46,7 @@ jobs: with: repository: 'opensearch-project/job-scheduler' path: job-scheduler - ref: 'main' + ref: '1.0' - name: Build job-scheduler working-directory: ./job-scheduler run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0 -Dbuild.snapshot=false diff --git a/build.gradle b/build.gradle index de4678107..869137508 100644 --- a/build.gradle +++ b/build.gradle @@ -271,6 +271,12 @@ testClusters.integTest { })) } setting 'path.repo', repo.absolutePath + + if (System.getProperty("tests.clustername") != null) { + filter { + excludeTestsMatching "org.opensearch.indexmanagement.indexstatemanagement.MetadataRegressionIT" + } + } } integTest { systemProperty 'tests.security.manager', 'false' diff --git a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt index afff48de5..291d10300 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt @@ -335,6 +335,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin .registerScriptService(scriptService) .registerSettings(settings) .registerConsumers() // registerConsumers must happen after registerSettings/clusterService + .registerIMIndex(indexManagementIndices) .registerHistoryIndex(indexStateManagementHistory) .registerSkipFlag(skipFlag) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt index 510fcd545..4441d475d 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt @@ -569,6 +569,8 @@ class ManagedIndexCoordinator( @OpenForTesting @Suppress("TooGenericExceptionCaught") suspend fun clearManagedIndexMetaData(deleteRequests: List>) { + if (!ismIndices.indexManagementIndexExists()) return + try { if (deleteRequests.isEmpty()) return diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt index 883e45832..865be64d8 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt @@ -63,6 +63,7 @@ import org.opensearch.common.xcontent.XContentType import org.opensearch.index.Index import org.opensearch.index.engine.VersionConflictEngineException import org.opensearch.index.seqno.SequenceNumbers +import org.opensearch.indexmanagement.IndexManagementIndices import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.INDEX_MANAGEMENT_INDEX import org.opensearch.indexmanagement.indexstatemanagement.action.Action import org.opensearch.indexmanagement.indexstatemanagement.model.ManagedIndexConfig @@ -130,6 +131,7 @@ object ManagedIndexRunner : private lateinit var xContentRegistry: NamedXContentRegistry private lateinit var scriptService: ScriptService private lateinit var settings: Settings + private lateinit var imIndices: IndexManagementIndices private lateinit var ismHistory: IndexStateManagementHistory private lateinit var skipExecFlag: SkipExecution private var indexStateManagementEnabled: Boolean = DEFAULT_ISM_ENABLED @@ -189,6 +191,11 @@ object ManagedIndexRunner : return this } + fun registerIMIndex(imIndices: IndexManagementIndices): ManagedIndexRunner { + this.imIndices = imIndices + return this + } + fun registerHistoryIndex(ismHistory: IndexStateManagementHistory): ManagedIndexRunner { this.ismHistory = ismHistory return this @@ -598,6 +605,10 @@ object ManagedIndexRunner : lastUpdateResult: UpdateMetadataResult? = null ): UpdateMetadataResult { var result = UpdateMetadataResult() + if (!imIndices.attemptUpdateConfigIndexMapping()) { + logger.error("Failed to update config index mapping.") + return result + } var metadata: ManagedIndexMetaData = managedIndexMetaData if (lastUpdateResult != null) { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ManagedIndexConfig.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ManagedIndexConfig.kt index 94b441c64..0645c0b2f 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ManagedIndexConfig.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ManagedIndexConfig.kt @@ -189,6 +189,7 @@ data class ManagedIndexConfig( policySeqNo = policySeqNo, policyPrimaryTerm = policyPrimaryTerm, policy = policy?.copy( + id = policyID ?: NO_ID, seqNo = policySeqNo ?: SequenceNumbers.UNASSIGNED_SEQ_NO, primaryTerm = policyPrimaryTerm ?: SequenceNumbers.UNASSIGNED_PRIMARY_TERM ), diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/TestHelpers.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/TestHelpers.kt index 6a947e30c..3cbef7a25 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/TestHelpers.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/TestHelpers.kt @@ -288,7 +288,7 @@ fun randomManagedIndexConfig( policyID = policy?.id ?: policyID, policySeqNo = policy?.seqNo, policyPrimaryTerm = policy?.primaryTerm, - policy = policy?.copy(id = ManagedIndexConfig.NO_ID, seqNo = SequenceNumbers.UNASSIGNED_SEQ_NO, primaryTerm = SequenceNumbers.UNASSIGNED_PRIMARY_TERM), + policy = policy?.copy(seqNo = SequenceNumbers.UNASSIGNED_SEQ_NO, primaryTerm = SequenceNumbers.UNASSIGNED_PRIMARY_TERM), changePolicy = changePolicy ) }