diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementHistory.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementHistory.kt index 763603ecc..2b846f9e3 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementHistory.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementHistory.kt @@ -19,7 +19,7 @@ import org.opensearch.action.index.IndexRequest import org.opensearch.action.support.IndicesOptions import org.opensearch.action.support.master.AcknowledgedResponse import org.opensearch.client.Client -import org.opensearch.cluster.LocalNodeMasterListener +import org.opensearch.cluster.LocalNodeClusterManagerListener import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.common.xcontent.ToXContent @@ -47,7 +47,7 @@ class IndexStateManagementHistory( private val threadPool: ThreadPool, private val clusterService: ClusterService, private val indexManagementIndices: IndexManagementIndices -) : LocalNodeMasterListener { +) : LocalNodeClusterManagerListener { private val logger = LogManager.getLogger(javaClass) private var scheduledRollover: Scheduler.Cancellable? = null @@ -61,7 +61,7 @@ class IndexStateManagementHistory( @Volatile private var historyNumberOfReplicas = ManagedIndexSettings.HISTORY_NUMBER_OF_REPLICAS.get(settings) init { - clusterService.addLocalNodeMasterListener(this) + clusterService.addLocalNodeClusterManagerListener(this) clusterService.clusterSettings.addSettingsUpdateConsumer(ManagedIndexSettings.HISTORY_ENABLED) { historyEnabled = it } @@ -82,7 +82,7 @@ class IndexStateManagementHistory( } } - override fun onMaster() { + override fun onClusterManager() { try { // try to rollover immediately as we might be restarting the cluster if (historyEnabled) rolloverHistoryIndex() @@ -97,12 +97,12 @@ class IndexStateManagementHistory( } } - override fun offMaster() { + override fun offClusterManager() { scheduledRollover?.cancel() } private fun rescheduleRollover() { - if (clusterService.state().nodes.isLocalNodeElectedMaster) { + if (clusterService.state().nodes.isLocalNodeElectedClusterManager) { scheduledRollover?.cancel() scheduledRollover = threadPool.scheduleWithFixedDelay( { rolloverAndDeleteHistoryIndex() }, diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt index 26d1ac590..fe7d90493 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt @@ -202,8 +202,8 @@ class ManagedIndexCoordinator( // Instead of using a LocalNodeMasterListener to track cluster manager changes, this service will // track them here to avoid conditions where cluster manager listener events run after other // listeners that depend on what happened in the cluster manager listener - if (this.isClusterManager != event.localNodeMaster()) { - this.isClusterManager = event.localNodeMaster() + if (this.isClusterManager != event.localNodeClusterManager()) { + this.isClusterManager = event.localNodeClusterManager() if (this.isClusterManager) { onClusterManager() } else { @@ -215,7 +215,7 @@ class ManagedIndexCoordinator( if (event.isNewCluster) return - if (!event.localNodeMaster()) return + if (!event.localNodeClusterManager()) return if (!event.metadataChanged()) return @@ -474,7 +474,7 @@ class ManagedIndexCoordinator( if (!isIndexStateManagementEnabled()) return // Do not setup background sweep if we're not the elected cluster manager node - if (!clusterService.state().nodes().isLocalNodeElectedMaster) return + if (!clusterService.state().nodes().isLocalNodeElectedClusterManager) return // Cancel existing background sweep scheduledFullSweep?.cancel() @@ -505,7 +505,7 @@ class ManagedIndexCoordinator( fun initMoveMetadata() { if (!metadataServiceEnabled) return if (!isIndexStateManagementEnabled()) return - if (!clusterService.state().nodes().isLocalNodeElectedMaster) return + if (!clusterService.state().nodes().isLocalNodeElectedClusterManager) return scheduledMoveMetadata?.cancel() if (metadataService.finishFlag) { @@ -535,7 +535,7 @@ class ManagedIndexCoordinator( fun initTemplateMigration(enableSetting: Long) { if (!templateMigrationEnabled) return if (!isIndexStateManagementEnabled()) return - if (!clusterService.state().nodes().isLocalNodeElectedMaster) return + if (!clusterService.state().nodes().isLocalNodeElectedClusterManager) return scheduledTemplateMigration?.cancel() // if service has finished, re-enable it diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt index d4c1c9e3f..6f8a0133c 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt @@ -253,7 +253,6 @@ object ManagedIndexRunner : // the cluster state index uuid differs from the one in the managed index config then the config is referring // to a different index which does not exist in the cluster. We need to check all of the extensions to confirm an index exists if (clusterStateIndexMetadata == null || clusterStateIndexUUID != managedIndexConfig.indexUuid) { - clusterStateIndexMetadata = null // If the cluster state/default index type didn't have an index with a matching name and uuid combination, try all other index types val nonDefaultIndexTypes = indexMetadataProvider.services.keys.filter { it != DEFAULT_INDEX_TYPE } val multiTypeIndexNameToMetaData = 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 acaabc864..9a87bc1d0 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ManagedIndexConfig.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ManagedIndexConfig.kt @@ -178,7 +178,7 @@ data class ManagedIndexConfig( policySeqNo = policySeqNo, policyPrimaryTerm = policyPrimaryTerm, policy = policy?.copy( - id = policyID ?: NO_ID, + id = policyID, seqNo = policySeqNo ?: SequenceNumbers.UNASSIGNED_SEQ_NO, primaryTerm = policyPrimaryTerm ?: SequenceNumbers.UNASSIGNED_PRIMARY_TERM ), diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/close/AttemptCloseStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/close/AttemptCloseStep.kt index bab8423e8..3e02ecb91 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/close/AttemptCloseStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/close/AttemptCloseStep.kt @@ -44,7 +44,7 @@ class AttemptCloseStep : Step(name) { } catch (e: RemoteTransportException) { val cause = ExceptionsHelper.unwrapCause(e) if (cause is SnapshotInProgressException) { - handleSnapshotException(indexName, cause as SnapshotInProgressException) + handleSnapshotException(indexName, cause) } else { handleException(indexName, cause as Exception) }