From a0d88f4dee9ddafaa8fa8dd769c0d15fc43e21e8 Mon Sep 17 00:00:00 2001 From: bowenlan-amzn Date: Wed, 11 Oct 2023 10:28:55 -0700 Subject: [PATCH] fix bug Signed-off-by: bowenlan-amzn --- .../indexstatemanagement/ManagedIndexRunner.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt index f80959661..3825fa509 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt @@ -464,7 +464,7 @@ object ManagedIndexRunner : } private suspend fun initManagedIndex(managedIndexConfig: ManagedIndexConfig) { - var policy: Policy = managedIndexConfig.policy + val policy: Policy = managedIndexConfig.policy var metadata = getInitializedManagedIndexMetaData(managedIndexConfig, policy, policy.id) // User may change policy before first metadata initialization @@ -472,14 +472,13 @@ object ManagedIndexRunner : val policyID = managedIndexConfig.changePolicy.policyID val newPolicy = getPolicy(policyID) if (newPolicy != null) { - policy = newPolicy - val saved = savePolicyToManagedIndexConfig(managedIndexConfig, policy) + val saved = savePolicyToManagedIndexConfig(managedIndexConfig, newPolicy) if (!saved) { logger.error("Failed to save policy to ManagedIndexConfig(${managedIndexConfig.index})") return } } - metadata = getInitializedManagedIndexMetaData(managedIndexConfig, policy, policyID) + metadata = getInitializedManagedIndexMetaData(managedIndexConfig, newPolicy, policyID) } updateManagedIndexMetaData(metadata, create = true)