From 9ab10b56b060ddb64564fa42dd6bbcfa8e31e99c Mon Sep 17 00:00:00 2001 From: harycash Date: Thu, 4 Jul 2024 14:01:46 +0530 Subject: [PATCH] Build issues fixed Signed-off-by: harycash --- .../indexstatemanagement/Step.kt | 17 +++++++++++++---- .../metrics/IndexManagementActionsMetrics.kt | 2 +- .../step/rollover/AttemptRolloverStep.kt | 11 +++++------ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Step.kt b/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Step.kt index ce347ac1a..b6fb65187 100644 --- a/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Step.kt +++ b/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Step.kt @@ -36,6 +36,16 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) { ): Step { logger.info("Finished executing $name for ${context?.metadata?.index}") val updatedStepMetaData = step.getUpdatedManagedIndexMetadata(startingManagedIndexMetaData) + emitTelemetry(indexManagementActionMetrics, updatedStepMetaData, logger) + this.context = null + return this + } + + private fun emitTelemetry( + indexManagementActionMetrics: IndexManagementActionsMetrics, + updatedStepMetaData: ManagedIndexMetaData, + logger: Logger, + ) { when (context?.metadata?.actionMetaData?.name) { IndexManagementActionsMetrics.ROLLOVER -> indexManagementActionMetrics.getActionMetrics( IndexManagementActionsMetrics.ROLLOVER, @@ -61,6 +71,7 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) { IndexManagementActionsMetrics.TRANSITION, ) ?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData) + IndexManagementActionsMetrics.NOTIFICATION -> indexManagementActionMetrics.getActionMetrics( IndexManagementActionsMetrics.NOTIFICATION, ) @@ -110,6 +121,7 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) { IndexManagementActionsMetrics.ALLOCATION, ) ?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData) + else -> { logger.info( "Action Metrics is not supported for this action [%s]", @@ -117,8 +129,6 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) { ) } } - this.context = null - return this } abstract fun getUpdatedManagedIndexMetadata(currentMetadata: ManagedIndexMetaData): ManagedIndexMetaData @@ -137,8 +147,7 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) { } } - final fun getStartingStepMetaData(metadata: ManagedIndexMetaData): StepMetaData = - StepMetaData(name, getStepStartTime(metadata).toEpochMilli(), StepStatus.STARTING) + final fun getStartingStepMetaData(metadata: ManagedIndexMetaData): StepMetaData = StepMetaData(name, getStepStartTime(metadata).toEpochMilli(), StepStatus.STARTING) enum class StepStatus(val status: String) : Writeable { STARTING("starting"), diff --git a/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/IndexManagementActionsMetrics.kt b/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/IndexManagementActionsMetrics.kt index 8dc8345b2..725893a21 100644 --- a/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/IndexManagementActionsMetrics.kt +++ b/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/IndexManagementActionsMetrics.kt @@ -33,7 +33,7 @@ abstract class ActionMetrics { .addTag("index_name", context.metadata.index) .addTag("policy_id", context.metadata.policyID) .addTag("node_id", context.clusterService.nodeName ?: "") - .addTag("Index_uuid", context.metadata.indexUuid) + .addTag("index_uuid", context.metadata.indexUuid) return tags } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt index f01c33e1b..5b7d455d5 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt @@ -305,12 +305,11 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { // ISM cannot auto recover from this case, so the status is COMPLETED logger.error("$indexName rolled over but cannot find the rolledOverIndexName to copy aliases to") stepStatus = StepStatus.COMPLETED - info = listOfNotNull( - - "message" to getCopyAliasRolledOverIndexNotFoundMessage(indexName), - if (conditions != null) "conditions" to conditions else null, - - ).toMap() + info = + listOfNotNull( + "message" to getCopyAliasRolledOverIndexNotFoundMessage(indexName), + if (conditions != null) "conditions" to conditions else null, + ).toMap() return }