diff --git a/src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt b/src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt index 473844865..0da24de23 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupMapperService.kt @@ -95,7 +95,7 @@ class RollupMapperService( @Suppress("ReturnCount") suspend fun validateTargetIndexAlias(rollup: Rollup, targetIndexResolvedName: String): RollupJobValidationResult { - var errorMessage: String + val errorMessage: String if (!RollupFieldValueExpressionResolver.indexAliasUtils.hasAlias(targetIndexResolvedName)) { logger.error("[${rollup.targetIndex}] is not an alias!") @@ -106,7 +106,7 @@ class RollupMapperService( if (rollupJobs != null && (rollupJobs.size > 1 || rollupJobs[0].id != rollup.id) ) { - errorMessage = "More than one rollup job present on the backing index, cannot add alias for target index: [$targetIndexResolvedName]" + errorMessage = "More than one rollup jobs present on the backing index of the target alias, cannot perform rollup to this target alias [${rollup.targetIndex}]." logger.error(errorMessage) return RollupJobValidationResult.Failure(errorMessage) } diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/runner/RollupRunnerIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/runner/RollupRunnerIT.kt index 51ca788b0..3dd8eee1b 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/runner/RollupRunnerIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/runner/RollupRunnerIT.kt @@ -5,7 +5,6 @@ package org.opensearch.indexmanagement.rollup.runner -import com.carrotsearch.randomizedtesting.RandomizedTest.sleep import org.apache.http.entity.ContentType import org.apache.http.entity.StringEntity import org.opensearch.common.settings.Settings @@ -1146,7 +1145,7 @@ class RollupRunnerIT : RollupRestTestCase() { waitFor { assertTrue("Target rollup index was not created", indexExists(backingIndex1)) } - var startedRollup1 = waitFor { + val startedRollup1 = waitFor { val rollupJob = getRollup(rollupId = job1.id) assertNotNull("Rollup job doesn't have metadata set", rollupJob.metadataID) val rollupMetadata = getRollupMetadata(rollupJob.metadataID!!) @@ -1165,7 +1164,7 @@ class RollupRunnerIT : RollupRestTestCase() { // Job2 First run, it should fail because job1 already wrote to backing index updateRollupStartTime(job2) - var startedRollup2 = waitFor { + val startedRollup2 = waitFor { val rollupJob = getRollup(rollupId = job2.id) assertNotNull("Rollup job doesn't have metadata set", rollupJob.metadataID) val rollupMetadata = getRollupMetadata(rollupJob.metadataID!!) @@ -1175,7 +1174,7 @@ class RollupRunnerIT : RollupRestTestCase() { } rollupMetadataID = startedRollup2.metadataID!! rollupMetadata = getRollupMetadata(rollupMetadataID) - assertEquals("If target_index is alias, write backing index must be used only by this rollup job: [$backingIndex1]", rollupMetadata.failureReason) + assertEquals("More than one rollup jobs present on the backing index of the target alias, cannot perform rollup to this target alias [$indexAlias].", rollupMetadata.failureReason) } fun `test rollup action with alias as target_index multiple empty backing indices`() {