From 83d53d5d2bc181e1d3de2e7854446290d3ca7383 Mon Sep 17 00:00:00 2001 From: harycash Date: Tue, 11 Jun 2024 12:50:26 +0530 Subject: [PATCH 1/4] Initial integration of TelemetryAwarePlugin to ISM Signed-off-by: harycash --- .../indexmanagement/IndexManagementPlugin.kt | 28 ++++++++-------- .../IndexManagementActionsMetrics.kt | 33 +++++++++++++++++++ 2 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexManagementActionsMetrics.kt diff --git a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt index 3a67de075..c536c7881 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt @@ -41,15 +41,7 @@ import org.opensearch.indexmanagement.controlcenter.notification.filter.IndexOpe import org.opensearch.indexmanagement.controlcenter.notification.resthandler.RestDeleteLRONConfigAction import org.opensearch.indexmanagement.controlcenter.notification.resthandler.RestGetLRONConfigAction import org.opensearch.indexmanagement.controlcenter.notification.resthandler.RestIndexLRONConfigAction -import org.opensearch.indexmanagement.indexstatemanagement.DefaultIndexMetadataService -import org.opensearch.indexmanagement.indexstatemanagement.ExtensionStatusChecker -import org.opensearch.indexmanagement.indexstatemanagement.ISMActionsParser -import org.opensearch.indexmanagement.indexstatemanagement.IndexMetadataProvider -import org.opensearch.indexmanagement.indexstatemanagement.IndexStateManagementHistory -import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexCoordinator -import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner -import org.opensearch.indexmanagement.indexstatemanagement.PluginVersionSweepCoordinator -import org.opensearch.indexmanagement.indexstatemanagement.SkipExecution +import org.opensearch.indexmanagement.indexstatemanagement.* import org.opensearch.indexmanagement.indexstatemanagement.model.ManagedIndexConfig import org.opensearch.indexmanagement.indexstatemanagement.model.Policy import org.opensearch.indexmanagement.indexstatemanagement.resthandler.RestAddPolicyAction @@ -179,15 +171,13 @@ import org.opensearch.jobscheduler.spi.JobSchedulerExtension import org.opensearch.jobscheduler.spi.ScheduledJobParser import org.opensearch.jobscheduler.spi.ScheduledJobRunner import org.opensearch.monitor.jvm.JvmService -import org.opensearch.plugins.ActionPlugin -import org.opensearch.plugins.ExtensiblePlugin -import org.opensearch.plugins.NetworkPlugin -import org.opensearch.plugins.Plugin -import org.opensearch.plugins.SystemIndexPlugin +import org.opensearch.plugins.* import org.opensearch.repositories.RepositoriesService import org.opensearch.rest.RestController import org.opensearch.rest.RestHandler import org.opensearch.script.ScriptService +import org.opensearch.telemetry.metrics.MetricsRegistry +import org.opensearch.telemetry.tracing.Tracer import org.opensearch.threadpool.ThreadPool import org.opensearch.transport.RemoteClusterService import org.opensearch.transport.TransportInterceptor @@ -196,7 +186,8 @@ import org.opensearch.watcher.ResourceWatcherService import java.util.function.Supplier @Suppress("TooManyFunctions") -class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin, ExtensiblePlugin, SystemIndexPlugin, Plugin() { +class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin, ExtensiblePlugin, SystemIndexPlugin, + TelemetryAwarePlugin, Plugin() { private val logger = LogManager.getLogger(javaClass) lateinit var indexManagementIndices: IndexManagementIndices lateinit var actionValidation: ActionValidation @@ -210,6 +201,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin private val extensions = mutableSetOf() private val extensionCheckerMap = mutableMapOf() lateinit var indexOperationActionFilter: IndexOperationActionFilter + private lateinit var metricsRegistry: MetricsRegistry companion object { const val PLUGINS_BASE_URI = "/_plugins" @@ -374,8 +366,11 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin namedWriteableRegistry: NamedWriteableRegistry, indexNameExpressionResolver: IndexNameExpressionResolver, repositoriesServiceSupplier: Supplier, + tracer: Tracer, + metricsRegistry: MetricsRegistry, ): Collection { val settings = environment.settings() + this.metricsRegistry = metricsRegistry this.clusterService = clusterService QueryShardContextFactory.init( client, @@ -385,6 +380,8 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin namedWriteableRegistry, environment, ) + + IndexManagementActionsMetrics.instance.initialize(metricsRegistry) rollupInterceptor = RollupInterceptor(clusterService, settings, indexNameExpressionResolver) val jvmService = JvmService(environment.settings()) val transformRunner = @@ -453,6 +450,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin .registerThreadPool(threadPool) .registerExtensionChecker(extensionChecker) .registerIndexMetadataProvider(indexMetadataProvider) + .registerIndexManagementActionMetrics(IndexManagementActionsMetrics.instance) val managedIndexCoordinator = ManagedIndexCoordinator( diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexManagementActionsMetrics.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexManagementActionsMetrics.kt new file mode 100644 index 000000000..df3458f2b --- /dev/null +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexManagementActionsMetrics.kt @@ -0,0 +1,33 @@ +package org.opensearch.indexmanagement.indexstatemanagement + +import org.opensearch.indexmanagement.indexstatemanagement.actionmetrics.RolloverActionMetrics +import org.opensearch.telemetry.metrics.MetricsRegistry + +abstract class ActionMetrics { + abstract val actionName: String +} + +class IndexManagementActionsMetrics private constructor() { + private lateinit var metricsRegistry: MetricsRegistry + private lateinit var actionMetricsMap: Map + + fun initialize(metricsRegistry: MetricsRegistry) { + this.metricsRegistry = metricsRegistry + actionMetricsMap = mapOf( + "rollover" to RolloverActionMetrics(metricsRegistry), + // Add other action metrics here + ) + } + + fun getActionMetrics(actionName: String): ActionMetrics? { + return actionMetricsMap[actionName] + } + + companion object { + val instance: IndexManagementActionsMetrics by lazy { HOLDER.instance } + } + + private object HOLDER { + val instance = IndexManagementActionsMetrics() + } +} From 681d015cd457372ab5cee88fdf21d2640a27abdc Mon Sep 17 00:00:00 2001 From: harycash Date: Wed, 12 Jun 2024 22:55:53 +0530 Subject: [PATCH 2/4] Initial integration of TelemetryAwarePlugin to ISM Signed-off-by: harycash --- .../metrics}/IndexManagementActionsMetrics.kt | 9 ++++--- .../actionmetrics/RolloverActionMetrics.kt | 24 +++++++++++++++++++ .../indexmanagement/IndexManagementPlugin.kt | 18 ++++++++++++-- .../ManagedIndexRunner.kt | 9 ++++++- .../step/rollover/AttemptRolloverStep.kt | 15 +++++++++++- 5 files changed, 68 insertions(+), 7 deletions(-) rename {src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement => spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics}/IndexManagementActionsMetrics.kt (71%) create mode 100644 spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/actionmetrics/RolloverActionMetrics.kt diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexManagementActionsMetrics.kt b/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/IndexManagementActionsMetrics.kt similarity index 71% rename from src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexManagementActionsMetrics.kt rename to spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/IndexManagementActionsMetrics.kt index df3458f2b..def480ab7 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexManagementActionsMetrics.kt +++ b/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/IndexManagementActionsMetrics.kt @@ -1,6 +1,6 @@ -package org.opensearch.indexmanagement.indexstatemanagement +package org.opensearch.indexmanagement.spi.indexstatemanagement.metrics -import org.opensearch.indexmanagement.indexstatemanagement.actionmetrics.RolloverActionMetrics +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.actionmetrics.RolloverActionMetrics import org.opensearch.telemetry.metrics.MetricsRegistry abstract class ActionMetrics { @@ -13,8 +13,11 @@ class IndexManagementActionsMetrics private constructor() { fun initialize(metricsRegistry: MetricsRegistry) { this.metricsRegistry = metricsRegistry + + RolloverActionMetrics.instance.initializeCounters(metricsRegistry, "rollover") + actionMetricsMap = mapOf( - "rollover" to RolloverActionMetrics(metricsRegistry), + "rollover" to RolloverActionMetrics.instance, // Add other action metrics here ) } diff --git a/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/actionmetrics/RolloverActionMetrics.kt b/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/actionmetrics/RolloverActionMetrics.kt new file mode 100644 index 000000000..48e67b0d7 --- /dev/null +++ b/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/metrics/actionmetrics/RolloverActionMetrics.kt @@ -0,0 +1,24 @@ +package org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.actionmetrics + +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.ActionMetrics +import org.opensearch.telemetry.metrics.Counter +import org.opensearch.telemetry.metrics.MetricsRegistry + +class RolloverActionMetrics private constructor() : ActionMetrics() { + override val actionName: String = "rollover_action" + lateinit var successes: Counter + lateinit var failures: Counter + + fun initializeCounters(metricsRegistry: MetricsRegistry, actionName: String) { + successes = metricsRegistry.createCounter("${actionName}_successes", "Rollover Action Successes", "count") + failures = metricsRegistry.createCounter("${actionName}_failures", "Rollover Action Failures", "count") + } + + companion object { + val instance: RolloverActionMetrics by lazy { HOLDER.instance } + } + + private object HOLDER { + val instance = RolloverActionMetrics() + } +} diff --git a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt index c536c7881..7660d48e1 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt @@ -41,7 +41,15 @@ import org.opensearch.indexmanagement.controlcenter.notification.filter.IndexOpe import org.opensearch.indexmanagement.controlcenter.notification.resthandler.RestDeleteLRONConfigAction import org.opensearch.indexmanagement.controlcenter.notification.resthandler.RestGetLRONConfigAction import org.opensearch.indexmanagement.controlcenter.notification.resthandler.RestIndexLRONConfigAction -import org.opensearch.indexmanagement.indexstatemanagement.* +import org.opensearch.indexmanagement.indexstatemanagement.DefaultIndexMetadataService +import org.opensearch.indexmanagement.indexstatemanagement.ExtensionStatusChecker +import org.opensearch.indexmanagement.indexstatemanagement.ISMActionsParser +import org.opensearch.indexmanagement.indexstatemanagement.IndexMetadataProvider +import org.opensearch.indexmanagement.indexstatemanagement.IndexStateManagementHistory +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexCoordinator +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner +import org.opensearch.indexmanagement.indexstatemanagement.PluginVersionSweepCoordinator +import org.opensearch.indexmanagement.indexstatemanagement.SkipExecution import org.opensearch.indexmanagement.indexstatemanagement.model.ManagedIndexConfig import org.opensearch.indexmanagement.indexstatemanagement.model.Policy import org.opensearch.indexmanagement.indexstatemanagement.resthandler.RestAddPolicyAction @@ -137,6 +145,7 @@ import org.opensearch.indexmanagement.snapshotmanagement.settings.SnapshotManage import org.opensearch.indexmanagement.spi.IndexManagementExtension import org.opensearch.indexmanagement.spi.indexstatemanagement.IndexMetadataService import org.opensearch.indexmanagement.spi.indexstatemanagement.StatusChecker +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.transform.TargetIndexMappingService import org.opensearch.indexmanagement.transform.TransformRunner @@ -171,7 +180,12 @@ import org.opensearch.jobscheduler.spi.JobSchedulerExtension import org.opensearch.jobscheduler.spi.ScheduledJobParser import org.opensearch.jobscheduler.spi.ScheduledJobRunner import org.opensearch.monitor.jvm.JvmService -import org.opensearch.plugins.* +import org.opensearch.plugins.ActionPlugin +import org.opensearch.plugins.ExtensiblePlugin +import org.opensearch.plugins.NetworkPlugin +import org.opensearch.plugins.Plugin +import org.opensearch.plugins.SystemIndexPlugin +import org.opensearch.plugins.TelemetryAwarePlugin import org.opensearch.repositories.RepositoriesService import org.opensearch.rest.RestController import org.opensearch.rest.RestHandler diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt index ea7ed3765..6db0d079a 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt @@ -86,6 +86,7 @@ import org.opensearch.indexmanagement.opensearchapi.withClosableContext import org.opensearch.indexmanagement.spi.indexstatemanagement.Action import org.opensearch.indexmanagement.spi.indexstatemanagement.Step import org.opensearch.indexmanagement.spi.indexstatemanagement.Validate +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ActionMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.PolicyRetryInfoMetaData @@ -121,6 +122,7 @@ object ManagedIndexRunner : private lateinit var skipExecFlag: SkipExecution private lateinit var threadPool: ThreadPool private lateinit var extensionStatusChecker: ExtensionStatusChecker + lateinit var indexManagementActionMetrics: IndexManagementActionsMetrics private lateinit var indexMetadataProvider: IndexMetadataProvider private var indexStateManagementEnabled: Boolean = DEFAULT_ISM_ENABLED private var validationServiceEnabled: Boolean = DEFAULT_ACTION_VALIDATION_ENABLED @@ -221,6 +223,11 @@ object ManagedIndexRunner : return this } + fun registerIndexManagementActionMetrics(indexManagementActionsMetrics: IndexManagementActionsMetrics): Any { + this.indexManagementActionMetrics = indexManagementActionsMetrics + return this + } + override fun runJob(job: ScheduledJobParameter, context: JobExecutionContext) { if (job !is ManagedIndexConfig) { throw IllegalArgumentException("Invalid job type, found ${job.javaClass.simpleName} with id: ${context.jobId}") @@ -446,7 +453,7 @@ object ManagedIndexRunner : managedIndexConfig.id, settings, threadPool.threadContext, managedIndexConfig.policy.user, ), ) { - step.preExecute(logger, stepContext.getUpdatedContext(startingManagedIndexMetaData)).execute().postExecute(logger) + step.preExecute(logger, stepContext.getUpdatedContext(startingManagedIndexMetaData)).execute(indexManagementActionMetrics).postExecute(logger) } var executedManagedIndexMetaData = startingManagedIndexMetaData.getCompletedManagedIndexMetaData(action, step) 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 5b7d455d5..fb8f40d56 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 @@ -27,9 +27,12 @@ import org.opensearch.indexmanagement.indexstatemanagement.util.evaluateConditio import org.opensearch.indexmanagement.opensearchapi.getUsefulCauseString import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.actionmetrics.RolloverActionMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData +import org.opensearch.telemetry.metrics.tags.Tags import org.opensearch.transport.RemoteTransportException import java.time.Instant @@ -39,13 +42,17 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { private var stepStatus = StepStatus.STARTING private var info: Map? = null private var newIndex: String? = null // this variable holds the new index name if rollover is successful in this run + private lateinit var indexManagementActionsMetrics: IndexManagementActionsMetrics + private lateinit var actionMetrics: RolloverActionMetrics @Suppress("ComplexMethod", "LongMethod") - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionsMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val clusterService = context.clusterService val skipRollover = clusterService.state().metadata.index(indexName).getRolloverSkip() + this.indexManagementActionsMetrics = indexManagementActionsMetrics + this.actionMetrics = indexManagementActionsMetrics.getActionMetrics("rollover") as RolloverActionMetrics if (skipRollover) { stepStatus = StepStatus.COMPLETED info = mapOf("message" to getSkipRolloverMessage(indexName)) @@ -68,6 +75,7 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { if (!isDataStream && !preCheckIndexAlias(context, rolloverTarget)) { stepStatus = StepStatus.FAILED info = mapOf("message" to getFailedPreCheckMessage(indexName)) + actionMetrics.failures.add(1.0, Tags.create().addTag("index_name", context.metadata.index).addTag("policy_id", context.metadata.policyID).addTag("node_id", context.clusterService.nodeName)) return this } @@ -155,6 +163,7 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { logger.warn(message) stepStatus = StepStatus.FAILED info = mapOf("message" to message) + actionMetrics.failures.add(1.0, Tags.create().addTag("index_name", context.metadata.index).addTag("policy_id", context.metadata.policyID).addTag("node_id", context.clusterService.nodeName)) } return rolloverTarget to isDataStreamIndex @@ -211,6 +220,7 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { "message" to message, "shard_failures" to statsResponse.shardFailures.map { it.getUsefulCauseString() }, ) + actionMetrics.failures.add(1.0, Tags.create().addTag("index_name", context.metadata.index).addTag("policy_id", context.metadata.policyID).addTag("node_id", context.clusterService.nodeName)) } catch (e: RemoteTransportException) { handleException(indexName, ExceptionsHelper.unwrapCause(e) as Exception) } catch (e: Exception) { @@ -310,6 +320,7 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { "message" to getCopyAliasRolledOverIndexNotFoundMessage(indexName), if (conditions != null) "conditions" to conditions else null, ).toMap() + actionMetrics.successes.add(1.0, Tags.create().addTag("index_name", context?.metadata?.index).addTag("policy_id", context?.metadata?.policyID).addTag("node_id", context?.clusterService?.nodeName)) return } @@ -337,6 +348,7 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { val aliasRes: AcknowledgedResponse = client.admin().indices().suspendUntil { aliases(aliasReq, it) } if (aliasRes.isAcknowledged) { stepStatus = StepStatus.COMPLETED + actionMetrics.successes.add(1.0, Tags.create().addTag("index_name", context?.metadata?.index).addTag("policy_id", context?.metadata?.policyID).addTag("node_id", context?.clusterService?.nodeName)) info = listOfNotNull( "message" to getSuccessCopyAliasMessage(indexName, rolledOverIndexName), @@ -344,6 +356,7 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { ).toMap() } else { stepStatus = StepStatus.FAILED + actionMetrics.failures.add(1.0, Tags.create().addTag("index_name", context?.metadata?.index).addTag("policy_id", context?.metadata?.policyID).addTag("node_id", context?.clusterService?.nodeName)) info = listOfNotNull( "message" to getCopyAliasNotAckMessage(indexName, rolledOverIndexName), From c3b2846d0eb859f9fa9cad067bb150bf742c81a6 Mon Sep 17 00:00:00 2001 From: harycash Date: Thu, 13 Jun 2024 10:33:22 +0530 Subject: [PATCH 3/4] Initial integration of TelemetryAwarePlugin to ISM with Rollover Step Integration Signed-off-by: harycash --- .../indexstatemanagement/Step.kt | 3 ++- .../step/alias/AttemptAliasActionsStep.kt | 3 ++- .../step/allocation/AttemptAllocationStep.kt | 3 ++- .../step/close/AttemptCloseStep.kt | 3 ++- .../step/delete/AttemptDeleteStep.kt | 3 ++- .../forcemerge/AttemptCallForceMergeStep.kt | 3 ++- .../step/forcemerge/AttemptSetReadOnlyStep.kt | 3 ++- .../step/forcemerge/WaitForForceMergeStep.kt | 3 ++- .../AttemptSetIndexPriorityStep.kt | 3 ++- .../notification/AttemptNotificationStep.kt | 3 ++- .../step/open/AttemptOpenStep.kt | 3 ++- .../step/readonly/SetReadOnlyStep.kt | 3 ++- .../step/readwrite/SetReadWriteStep.kt | 3 ++- .../replicacount/AttemptReplicaCountStep.kt | 3 ++- .../step/rollup/AttemptCreateRollupJobStep.kt | 3 ++- .../rollup/WaitForRollupCompletionStep.kt | 3 ++- .../step/shrink/ShrinkStep.kt | 3 ++- .../step/snapshot/AttemptSnapshotStep.kt | 3 ++- .../step/snapshot/WaitForSnapshotStep.kt | 3 ++- .../AttemptCreateTransformJobStep.kt | 3 ++- .../WaitForTransformCompletionStep.kt | 3 ++- .../step/transition/AttemptTransitionStep.kt | 3 ++- .../extension/SampleCustomActionParser.kt | 3 ++- .../step/AttemptCloseStepTests.kt | 13 ++++++------ .../step/AttemptDeleteStepTests.kt | 9 ++++---- .../step/AttemptOpenStepTests.kt | 7 ++++--- .../step/AttemptRolloverStepTests.kt | 9 ++++---- .../step/AttemptSetIndexPriorityStepTests.kt | 9 ++++---- .../step/AttemptSetReplicaCountStepTests.kt | 7 ++++--- .../step/AttemptSnapshotStepTests.kt | 15 ++++++------- .../step/AttemptTransitionStepTests.kt | 7 ++++--- .../step/SetReadOnlyStepTests.kt | 7 ++++--- .../step/SetReadWriteStepTests.kt | 7 ++++--- .../step/WaitForRollupCompletionStepTests.kt | 3 ++- .../step/WaitForSnapshotStepTests.kt | 21 ++++++++++--------- .../WaitForTransformCompletionStepTests.kt | 3 ++- 36 files changed, 111 insertions(+), 75 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 8de821936..00faea817 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 @@ -9,6 +9,7 @@ import org.apache.logging.log4j.Logger import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.core.common.io.stream.StreamOutput import org.opensearch.core.common.io.stream.Writeable +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData @@ -25,7 +26,7 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) { return this } - abstract suspend fun execute(): Step + abstract suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step fun postExecute(logger: Logger): Step { logger.info("Finished executing $name for ${context?.metadata?.index}") diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/alias/AttemptAliasActionsStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/alias/AttemptAliasActionsStep.kt index f756fe547..64135ab59 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/alias/AttemptAliasActionsStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/alias/AttemptAliasActionsStep.kt @@ -11,6 +11,7 @@ import org.opensearch.action.support.master.AcknowledgedResponse import org.opensearch.indexmanagement.indexstatemanagement.action.AliasAction import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData @@ -19,7 +20,7 @@ class AttemptAliasActionsStep(private val action: AliasAction) : Step(name) { private var stepStatus = StepStatus.STARTING private var info: Map? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index try { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/allocation/AttemptAllocationStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/allocation/AttemptAllocationStep.kt index 1c42612ba..135ac31d3 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/allocation/AttemptAllocationStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/allocation/AttemptAllocationStep.kt @@ -12,6 +12,7 @@ import org.opensearch.common.settings.Settings import org.opensearch.indexmanagement.indexstatemanagement.action.AllocationAction import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData @@ -20,7 +21,7 @@ class AttemptAllocationStep(private val action: AllocationAction) : Step(name) { private var stepStatus = StepStatus.STARTING private var info: Map? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index try { 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 5e4b01fdd..b570366ed 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 @@ -11,6 +11,7 @@ import org.opensearch.action.admin.indices.close.CloseIndexRequest import org.opensearch.action.admin.indices.close.CloseIndexResponse import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.snapshots.SnapshotInProgressException @@ -21,7 +22,7 @@ class AttemptCloseStep : Step(name) { private var stepStatus = StepStatus.STARTING private var info: Map? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index try { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/delete/AttemptDeleteStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/delete/AttemptDeleteStep.kt index bbbc390d3..30cfab0dc 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/delete/AttemptDeleteStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/delete/AttemptDeleteStep.kt @@ -11,6 +11,7 @@ import org.opensearch.action.admin.indices.delete.DeleteIndexRequest import org.opensearch.action.support.master.AcknowledgedResponse import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.snapshots.SnapshotInProgressException @@ -21,7 +22,7 @@ class AttemptDeleteStep : Step(name) { private var stepStatus = StepStatus.STARTING private var info: Map? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index try { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/AttemptCallForceMergeStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/AttemptCallForceMergeStep.kt index 3ff796e55..564bc4e23 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/AttemptCallForceMergeStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/AttemptCallForceMergeStep.kt @@ -19,6 +19,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.action.ForceMergeActi import org.opensearch.indexmanagement.opensearchapi.getUsefulCauseString import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ActionProperties import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData @@ -31,7 +32,7 @@ class AttemptCallForceMergeStep(private val action: ForceMergeAction) : Step(nam private var info: Map? = null @Suppress("TooGenericExceptionCaught", "ComplexMethod") - override suspend fun execute(): AttemptCallForceMergeStep { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): AttemptCallForceMergeStep { val context = this.context ?: return this val indexName = context.metadata.index try { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/AttemptSetReadOnlyStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/AttemptSetReadOnlyStep.kt index 1f931404b..1d477238e 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/AttemptSetReadOnlyStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/AttemptSetReadOnlyStep.kt @@ -14,6 +14,7 @@ import org.opensearch.common.settings.Settings import org.opensearch.indexmanagement.indexstatemanagement.action.ForceMergeAction import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData @@ -25,7 +26,7 @@ class AttemptSetReadOnlyStep(private val action: ForceMergeAction) : Step(name) private var info: Map? = null @Suppress("ReturnCount") - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val indexSetToReadOnly = setIndexToReadOnly(indexName, context) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/WaitForForceMergeStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/WaitForForceMergeStep.kt index 612739251..cacee486e 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/WaitForForceMergeStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/forcemerge/WaitForForceMergeStep.kt @@ -13,6 +13,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.action.ForceMergeActi import org.opensearch.indexmanagement.opensearchapi.getUsefulCauseString import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ActionProperties import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext @@ -26,7 +27,7 @@ class WaitForForceMergeStep(private val action: ForceMergeAction) : Step(name, f private var info: Map? = null @Suppress("TooGenericExceptionCaught", "ReturnCount") - override suspend fun execute(): WaitForForceMergeStep { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): WaitForForceMergeStep { val context = this.context ?: return this val indexName = context.metadata.index // Retrieve maxNumSegments value from ActionProperties. If ActionProperties is null, update failed info and return early. diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/indexpriority/AttemptSetIndexPriorityStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/indexpriority/AttemptSetIndexPriorityStep.kt index 09aaa5b0b..1aa49ae92 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/indexpriority/AttemptSetIndexPriorityStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/indexpriority/AttemptSetIndexPriorityStep.kt @@ -14,6 +14,7 @@ import org.opensearch.common.settings.Settings import org.opensearch.indexmanagement.indexstatemanagement.action.IndexPriorityAction import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.transport.RemoteTransportException @@ -24,7 +25,7 @@ class AttemptSetIndexPriorityStep(private val action: IndexPriorityAction) : Ste private var info: Map? = null @Suppress("TooGenericExceptionCaught") - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val managedIndexMetaData = context.metadata diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/notification/AttemptNotificationStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/notification/AttemptNotificationStep.kt index 04cdd2bc0..4cc119806 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/notification/AttemptNotificationStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/notification/AttemptNotificationStep.kt @@ -11,6 +11,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.util.publishLegacyNot import org.opensearch.indexmanagement.indexstatemanagement.util.sendNotification import org.opensearch.indexmanagement.opensearchapi.convertToMap import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.script.Script @@ -22,7 +23,7 @@ class AttemptNotificationStep(private val action: NotificationAction) : Step(nam private var stepStatus = StepStatus.STARTING private var info: Map? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val scriptService = context.scriptService diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/open/AttemptOpenStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/open/AttemptOpenStep.kt index 7f384f845..4be84314e 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/open/AttemptOpenStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/open/AttemptOpenStep.kt @@ -11,6 +11,7 @@ import org.opensearch.action.admin.indices.open.OpenIndexRequest import org.opensearch.action.admin.indices.open.OpenIndexResponse import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.transport.RemoteTransportException @@ -20,7 +21,7 @@ class AttemptOpenStep : Step(name) { private var stepStatus = StepStatus.STARTING private var info: Map? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index try { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/readonly/SetReadOnlyStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/readonly/SetReadOnlyStep.kt index 2560bb208..61b6fe8ce 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/readonly/SetReadOnlyStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/readonly/SetReadOnlyStep.kt @@ -13,6 +13,7 @@ import org.opensearch.cluster.metadata.IndexMetadata.SETTING_BLOCKS_WRITE import org.opensearch.common.settings.Settings import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.transport.RemoteTransportException @@ -22,7 +23,7 @@ class SetReadOnlyStep : Step(name) { private var stepStatus = StepStatus.STARTING private var info: Map? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index try { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/readwrite/SetReadWriteStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/readwrite/SetReadWriteStep.kt index 11e634c7a..68b2815ab 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/readwrite/SetReadWriteStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/readwrite/SetReadWriteStep.kt @@ -13,6 +13,7 @@ import org.opensearch.cluster.metadata.IndexMetadata.SETTING_BLOCKS_WRITE import org.opensearch.common.settings.Settings import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.transport.RemoteTransportException @@ -22,7 +23,7 @@ class SetReadWriteStep : Step(name) { private var stepStatus = StepStatus.STARTING private var info: Map? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index try { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/replicacount/AttemptReplicaCountStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/replicacount/AttemptReplicaCountStep.kt index 68eccae8f..856711675 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/replicacount/AttemptReplicaCountStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/replicacount/AttemptReplicaCountStep.kt @@ -14,6 +14,7 @@ import org.opensearch.common.settings.Settings import org.opensearch.indexmanagement.indexstatemanagement.action.ReplicaCountAction import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.transport.RemoteTransportException @@ -24,7 +25,7 @@ class AttemptReplicaCountStep(private val action: ReplicaCountAction) : Step(nam private var info: Map? = null private val numOfReplicas = action.numOfReplicas - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index try { diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollup/AttemptCreateRollupJobStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollup/AttemptCreateRollupJobStep.kt index ee166ec4a..1ddc01a35 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollup/AttemptCreateRollupJobStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollup/AttemptCreateRollupJobStep.kt @@ -20,6 +20,7 @@ import org.opensearch.indexmanagement.rollup.action.index.IndexRollupResponse import org.opensearch.indexmanagement.rollup.action.start.StartRollupAction import org.opensearch.indexmanagement.rollup.action.start.StartRollupRequest import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ActionProperties import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext @@ -32,7 +33,7 @@ class AttemptCreateRollupJobStep(private val action: RollupAction) : Step(name) private var info: Map? = null private var rollupId: String? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val managedIndexMetadata = context.metadata diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollup/WaitForRollupCompletionStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollup/WaitForRollupCompletionStep.kt index 7bdc1f4be..c5c0efc94 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollup/WaitForRollupCompletionStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollup/WaitForRollupCompletionStep.kt @@ -12,6 +12,7 @@ import org.opensearch.indexmanagement.rollup.action.explain.ExplainRollupRequest import org.opensearch.indexmanagement.rollup.action.explain.ExplainRollupResponse import org.opensearch.indexmanagement.rollup.model.RollupMetadata import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.transport.RemoteTransportException @@ -22,7 +23,7 @@ class WaitForRollupCompletionStep : Step(name) { private var info: Map? = null private var hasRollupFailed: Boolean? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val managedIndexMetadata = context.metadata diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/shrink/ShrinkStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/shrink/ShrinkStep.kt index e0baae6a0..8e57a264e 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/shrink/ShrinkStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/shrink/ShrinkStep.kt @@ -18,6 +18,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.util.renewShrinkLock import org.opensearch.indexmanagement.indexstatemanagement.util.resetReadOnlyAndRouting import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ShrinkActionProperties import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext import org.opensearch.transport.RemoteTransportException @@ -34,7 +35,7 @@ abstract class ShrinkStep( protected var shrinkActionProperties: ShrinkActionProperties? = null @Suppress("ReturnCount") - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this try { wrappedExecute(context) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/snapshot/AttemptSnapshotStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/snapshot/AttemptSnapshotStep.kt index 6e02ad716..7561a305c 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/snapshot/AttemptSnapshotStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/snapshot/AttemptSnapshotStep.kt @@ -16,6 +16,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.settings.ManagedIndex import org.opensearch.indexmanagement.opensearchapi.convertToMap import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ActionProperties import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData @@ -37,7 +38,7 @@ class AttemptSnapshotStep(private val action: SnapshotAction) : Step(name) { private var snapshotName: String? = null @Suppress("TooGenericExceptionCaught", "ComplexMethod", "ReturnCount", "LongMethod") - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val managedIndexMetadata = context.metadata diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/snapshot/WaitForSnapshotStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/snapshot/WaitForSnapshotStep.kt index 36157f5c9..e1f6b8868 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/snapshot/WaitForSnapshotStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/snapshot/WaitForSnapshotStep.kt @@ -14,6 +14,7 @@ import org.opensearch.cluster.SnapshotsInProgress.State import org.opensearch.indexmanagement.indexstatemanagement.action.SnapshotAction import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ActionProperties import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData @@ -25,7 +26,7 @@ class WaitForSnapshotStep(private val action: SnapshotAction) : Step(name) { private var info: Map? = null @Suppress("ComplexMethod", "ReturnCount") - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val managedIndexMetadata = context.metadata diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transform/AttemptCreateTransformJobStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transform/AttemptCreateTransformJobStep.kt index 41aa6ff92..f79cda616 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transform/AttemptCreateTransformJobStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transform/AttemptCreateTransformJobStep.kt @@ -15,6 +15,7 @@ import org.opensearch.index.engine.VersionConflictEngineException import org.opensearch.indexmanagement.indexstatemanagement.action.TransformAction import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ActionProperties import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext @@ -35,7 +36,7 @@ class AttemptCreateTransformJobStep( private var info: Map? = null private var transformId: String? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val managedIndexMetadata = context.metadata diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transform/WaitForTransformCompletionStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transform/WaitForTransformCompletionStep.kt index 8b2085403..ac199b438 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transform/WaitForTransformCompletionStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transform/WaitForTransformCompletionStep.kt @@ -9,6 +9,7 @@ import org.apache.logging.log4j.LogManager import org.opensearch.ExceptionsHelper import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData @@ -24,7 +25,7 @@ class WaitForTransformCompletionStep : Step(name) { private var stepStatus = StepStatus.STARTING private var info: Map? = null - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val managedIndexMetadata = context.metadata diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transition/AttemptTransitionStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transition/AttemptTransitionStep.kt index cd12916cd..7dc74e693 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transition/AttemptTransitionStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transition/AttemptTransitionStep.kt @@ -21,6 +21,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.util.hasStatsConditio import org.opensearch.indexmanagement.opensearchapi.getUsefulCauseString import org.opensearch.indexmanagement.opensearchapi.suspendUntil import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData import org.opensearch.transport.RemoteTransportException @@ -34,7 +35,7 @@ class AttemptTransitionStep(private val action: TransitionsAction) : Step(name) private var info: Map? = null @Suppress("ReturnCount", "ComplexMethod", "LongMethod", "NestedBlockDepth") - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { val context = this.context ?: return this val indexName = context.metadata.index val clusterService = context.clusterService diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/extension/SampleCustomActionParser.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/extension/SampleCustomActionParser.kt index b896ef231..08c30df0f 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/extension/SampleCustomActionParser.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/extension/SampleCustomActionParser.kt @@ -14,6 +14,7 @@ import org.opensearch.core.xcontent.XContentParserUtils import org.opensearch.indexmanagement.spi.indexstatemanagement.Action import org.opensearch.indexmanagement.spi.indexstatemanagement.ActionParser import org.opensearch.indexmanagement.spi.indexstatemanagement.Step +import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData @@ -73,7 +74,7 @@ class SampleCustomActionParser : ActionParser() { class SampleCustomStep : Step(name) { private var stepStatus = StepStatus.STARTING - override suspend fun execute(): Step { + override suspend fun execute(indexManagementActionMetrics: IndexManagementActionsMetrics): Step { stepStatus = StepStatus.COMPLETED return this } diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptCloseStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptCloseStepTests.kt index a7e2851e6..f0ce7dfcf 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptCloseStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptCloseStepTests.kt @@ -18,6 +18,7 @@ import org.opensearch.client.IndicesAdminClient import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.step.close.AttemptCloseStep import org.opensearch.indexmanagement.spi.indexstatemanagement.Step import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData @@ -43,7 +44,7 @@ class AttemptCloseStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptCloseStep = AttemptCloseStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptCloseStep.preExecute(logger, context).execute() + attemptCloseStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptCloseStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not COMPLETED", Step.StepStatus.COMPLETED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -57,7 +58,7 @@ class AttemptCloseStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptCloseStep = AttemptCloseStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptCloseStep.preExecute(logger, context).execute() + attemptCloseStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptCloseStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -71,7 +72,7 @@ class AttemptCloseStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptCloseStep = AttemptCloseStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptCloseStep.preExecute(logger, context).execute() + attemptCloseStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptCloseStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -85,7 +86,7 @@ class AttemptCloseStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptCloseStep = AttemptCloseStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptCloseStep.preExecute(logger, context).execute() + attemptCloseStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptCloseStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not CONDITION_NOT_MET", Step.StepStatus.CONDITION_NOT_MET, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -99,7 +100,7 @@ class AttemptCloseStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptCloseStep = AttemptCloseStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptCloseStep.preExecute(logger, context).execute() + attemptCloseStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptCloseStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not CONDITION_NOT_MET", Step.StepStatus.CONDITION_NOT_MET, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -113,7 +114,7 @@ class AttemptCloseStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptCloseStep = AttemptCloseStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptCloseStep.preExecute(logger, context).execute() + attemptCloseStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptCloseStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "nested", updatedManagedIndexMetaData.info!!["cause"]) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptDeleteStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptDeleteStepTests.kt index 4dcd6e2f1..e3a23c09a 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptDeleteStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptDeleteStepTests.kt @@ -18,6 +18,7 @@ import org.opensearch.client.IndicesAdminClient import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.step.delete.AttemptDeleteStep import org.opensearch.indexmanagement.spi.indexstatemanagement.Step import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData @@ -41,7 +42,7 @@ class AttemptDeleteStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptDeleteStep = AttemptDeleteStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptDeleteStep.preExecute(logger, context).execute() + attemptDeleteStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptDeleteStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not COMPLETED", Step.StepStatus.COMPLETED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -55,7 +56,7 @@ class AttemptDeleteStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptDeleteStep = AttemptDeleteStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptDeleteStep.preExecute(logger, context).execute() + attemptDeleteStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptDeleteStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -69,7 +70,7 @@ class AttemptDeleteStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptDeleteStep = AttemptDeleteStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptDeleteStep.preExecute(logger, context).execute() + attemptDeleteStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptDeleteStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) logger.info(updatedManagedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) @@ -84,7 +85,7 @@ class AttemptDeleteStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptDeleteStep = AttemptDeleteStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptDeleteStep.preExecute(logger, context).execute() + attemptDeleteStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptDeleteStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not CONDITION_NOT_MET", Step.StepStatus.CONDITION_NOT_MET, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptOpenStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptOpenStepTests.kt index c0797e3d9..a06e54a4f 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptOpenStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptOpenStepTests.kt @@ -18,6 +18,7 @@ import org.opensearch.client.IndicesAdminClient import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.step.open.AttemptOpenStep import org.opensearch.indexmanagement.spi.indexstatemanagement.Step import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData @@ -41,7 +42,7 @@ class AttemptOpenStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptOpenStep = AttemptOpenStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptOpenStep.preExecute(logger, context).execute() + attemptOpenStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptOpenStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -55,7 +56,7 @@ class AttemptOpenStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptOpenStep = AttemptOpenStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptOpenStep.preExecute(logger, context).execute() + attemptOpenStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptOpenStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -69,7 +70,7 @@ class AttemptOpenStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptOpenStep = AttemptOpenStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptOpenStep.preExecute(logger, context).execute() + attemptOpenStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptOpenStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "nested", updatedManagedIndexMetaData.info!!["cause"]) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptRolloverStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptRolloverStepTests.kt index 69f674f12..beabc39d6 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptRolloverStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptRolloverStepTests.kt @@ -24,6 +24,7 @@ import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener import org.opensearch.index.IndexNotFoundException +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.action.RolloverAction import org.opensearch.indexmanagement.indexstatemanagement.settings.ManagedIndexSettings import org.opensearch.indexmanagement.indexstatemanagement.step.rollover.AttemptRolloverStep @@ -83,7 +84,7 @@ class AttemptRolloverStepTests : OpenSearchTestCase() { ) val attemptRolloverStep = AttemptRolloverStep(rolloverAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptRolloverStep.preExecute(logger, context).execute() + attemptRolloverStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptRolloverStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("message info is not matched", AttemptRolloverStep.getCopyAliasNotAckMessage(oldIndexName, newIndexName), updatedManagedIndexMetaData.info?.get("message")) @@ -108,7 +109,7 @@ class AttemptRolloverStepTests : OpenSearchTestCase() { ) val attemptRolloverStep = AttemptRolloverStep(rolloverAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptRolloverStep.preExecute(logger, context).execute() + attemptRolloverStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptRolloverStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("message info is not matched", AttemptRolloverStep.getFailedCopyAliasMessage(oldIndexName, newIndexName), updatedManagedIndexMetaData.info?.get("message")) @@ -133,7 +134,7 @@ class AttemptRolloverStepTests : OpenSearchTestCase() { ) val attemptRolloverStep = AttemptRolloverStep(rolloverAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptRolloverStep.preExecute(logger, context).execute() + attemptRolloverStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptRolloverStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("message info is not matched", AttemptRolloverStep.getCopyAliasIndexNotFoundMessage(newIndexName), updatedManagedIndexMetaData.info?.get("message")) @@ -158,7 +159,7 @@ class AttemptRolloverStepTests : OpenSearchTestCase() { ) val attemptRolloverStep = AttemptRolloverStep(rolloverAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptRolloverStep.preExecute(logger, context).execute() + attemptRolloverStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptRolloverStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not COMPLETED", Step.StepStatus.COMPLETED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("message info is not matched", AttemptRolloverStep.getCopyAliasRolledOverIndexNotFoundMessage(oldIndexName), updatedManagedIndexMetaData.info?.get("message")) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSetIndexPriorityStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSetIndexPriorityStepTests.kt index 6842b4dc4..cb580b9d4 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSetIndexPriorityStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSetIndexPriorityStepTests.kt @@ -18,6 +18,7 @@ import org.opensearch.client.IndicesAdminClient import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.action.IndexPriorityAction import org.opensearch.indexmanagement.indexstatemanagement.step.indexpriority.AttemptSetIndexPriorityStep import org.opensearch.indexmanagement.spi.indexstatemanagement.Step @@ -43,7 +44,7 @@ class AttemptSetIndexPriorityStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptSetPriorityStep = AttemptSetIndexPriorityStep(indexPriorityAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptSetPriorityStep.preExecute(logger, context).execute() + attemptSetPriorityStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptSetPriorityStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not COMPLETED", Step.StepStatus.COMPLETED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -58,7 +59,7 @@ class AttemptSetIndexPriorityStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptSetPriorityStep = AttemptSetIndexPriorityStep(indexPriorityAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptSetPriorityStep.preExecute(logger, context).execute() + attemptSetPriorityStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptSetPriorityStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -73,7 +74,7 @@ class AttemptSetIndexPriorityStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptSetPriorityStep = AttemptSetIndexPriorityStep(indexPriorityAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptSetPriorityStep.preExecute(logger, context).execute() + attemptSetPriorityStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptSetPriorityStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) logger.info(updatedManagedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) @@ -89,7 +90,7 @@ class AttemptSetIndexPriorityStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val attemptSetPriorityStep = AttemptSetIndexPriorityStep(indexPriorityAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - attemptSetPriorityStep.preExecute(logger, context).execute() + attemptSetPriorityStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptSetPriorityStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) logger.info(updatedManagedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSetReplicaCountStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSetReplicaCountStepTests.kt index 30f2e6639..4b29d594a 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSetReplicaCountStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSetReplicaCountStepTests.kt @@ -18,6 +18,7 @@ import org.opensearch.client.IndicesAdminClient import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.action.ReplicaCountAction import org.opensearch.indexmanagement.indexstatemanagement.step.replicacount.AttemptReplicaCountStep import org.opensearch.indexmanagement.spi.indexstatemanagement.Step @@ -43,7 +44,7 @@ class AttemptSetReplicaCountStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val replicaCountStep = AttemptReplicaCountStep(replicaCountAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - replicaCountStep.preExecute(logger, context).execute() + replicaCountStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = replicaCountStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -58,7 +59,7 @@ class AttemptSetReplicaCountStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val replicaCountStep = AttemptReplicaCountStep(replicaCountAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - replicaCountStep.preExecute(logger, context).execute() + replicaCountStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = replicaCountStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -73,7 +74,7 @@ class AttemptSetReplicaCountStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val replicaCountStep = AttemptReplicaCountStep(replicaCountAction) val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - replicaCountStep.preExecute(logger, context).execute() + replicaCountStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = replicaCountStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "nested", updatedManagedIndexMetaData.info!!["cause"]) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSnapshotStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSnapshotStepTests.kt index 2cc7040db..8024993dd 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSnapshotStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptSnapshotStepTests.kt @@ -22,6 +22,7 @@ import org.opensearch.common.settings.ClusterSettings import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener import org.opensearch.core.rest.RestStatus +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.randomSnapshotActionConfig import org.opensearch.indexmanagement.indexstatemanagement.settings.ManagedIndexSettings.Companion.SNAPSHOT_DENY_LIST import org.opensearch.indexmanagement.indexstatemanagement.step.snapshot.AttemptSnapshotStep @@ -60,7 +61,7 @@ class AttemptSnapshotStepTests : OpenSearchTestCase() { runBlocking { val step = AttemptSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not COMPLETED", Step.StepStatus.COMPLETED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -69,7 +70,7 @@ class AttemptSnapshotStepTests : OpenSearchTestCase() { runBlocking { val step = AttemptSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not COMPLETED", Step.StepStatus.COMPLETED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -78,7 +79,7 @@ class AttemptSnapshotStepTests : OpenSearchTestCase() { runBlocking { val step = AttemptSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -90,7 +91,7 @@ class AttemptSnapshotStepTests : OpenSearchTestCase() { runBlocking { val step = AttemptSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "example", updatedManagedIndexMetaData.info!!["cause"]) @@ -103,7 +104,7 @@ class AttemptSnapshotStepTests : OpenSearchTestCase() { runBlocking { val step = AttemptSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not CONDITION_NOT_MET", Step.StepStatus.CONDITION_NOT_MET, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get failed concurrent message", AttemptSnapshotStep.getFailedConcurrentSnapshotMessage("test"), updatedManagedIndexMetaData.info!!["message"]) @@ -116,7 +117,7 @@ class AttemptSnapshotStepTests : OpenSearchTestCase() { runBlocking { val step = AttemptSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not CONDITION_NOT_MET", Step.StepStatus.CONDITION_NOT_MET, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get failed concurrent message", AttemptSnapshotStep.getFailedConcurrentSnapshotMessage("test"), updatedManagedIndexMetaData.info!!["message"]) @@ -129,7 +130,7 @@ class AttemptSnapshotStepTests : OpenSearchTestCase() { runBlocking { val step = AttemptSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "some error", updatedManagedIndexMetaData.info!!["cause"]) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptTransitionStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptTransitionStepTests.kt index 496c4f3b4..d5900eb4d 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptTransitionStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptTransitionStepTests.kt @@ -28,6 +28,7 @@ import org.opensearch.core.action.ActionListener import org.opensearch.core.rest.RestStatus import org.opensearch.index.shard.DocsStats import org.opensearch.indexmanagement.indexstatemanagement.IndexMetadataProvider +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.action.TransitionsAction import org.opensearch.indexmanagement.indexstatemanagement.model.Conditions import org.opensearch.indexmanagement.indexstatemanagement.model.Transition @@ -87,7 +88,7 @@ class AttemptTransitionStepTests : OpenSearchTestCase() { val transitionsAction = TransitionsAction(listOf(Transition("some_state", Conditions(docCount = 5L))), indexMetadataProvider) val attemptTransitionStep = AttemptTransitionStep(transitionsAction) val context = StepContext(managedIndexMetadata, clusterService, client, null, null, scriptService, settings, lockService) - attemptTransitionStep.preExecute(logger, context).execute() + attemptTransitionStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptTransitionStep.getUpdatedManagedIndexMetadata(managedIndexMetadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get correct failed message", AttemptTransitionStep.getFailedStatsMessage(indexName), updatedManagedIndexMetaData.info!!["message"]) @@ -105,7 +106,7 @@ class AttemptTransitionStepTests : OpenSearchTestCase() { val transitionsAction = TransitionsAction(listOf(Transition("some_state", Conditions(docCount = 5L))), indexMetadataProvider) val attemptTransitionStep = AttemptTransitionStep(transitionsAction) val context = StepContext(managedIndexMetadata, clusterService, client, null, null, scriptService, settings, lockService) - attemptTransitionStep.preExecute(logger, context).execute() + attemptTransitionStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptTransitionStep.getUpdatedManagedIndexMetadata(managedIndexMetadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "example", updatedManagedIndexMetaData.info!!["cause"]) @@ -123,7 +124,7 @@ class AttemptTransitionStepTests : OpenSearchTestCase() { val transitionsAction = TransitionsAction(listOf(Transition("some_state", Conditions(docCount = 5L))), indexMetadataProvider) val attemptTransitionStep = AttemptTransitionStep(transitionsAction) val context = StepContext(managedIndexMetadata, clusterService, client, null, null, scriptService, settings, lockService) - attemptTransitionStep.preExecute(logger, context).execute() + attemptTransitionStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = attemptTransitionStep.getUpdatedManagedIndexMetadata(managedIndexMetadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "nested", updatedManagedIndexMetaData.info!!["cause"]) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/SetReadOnlyStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/SetReadOnlyStepTests.kt index a3a70ca6c..b9431f1a1 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/SetReadOnlyStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/SetReadOnlyStepTests.kt @@ -18,6 +18,7 @@ import org.opensearch.client.IndicesAdminClient import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.step.readonly.SetReadOnlyStep import org.opensearch.indexmanagement.spi.indexstatemanagement.Step import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData @@ -41,7 +42,7 @@ class SetReadOnlyStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val setReadOnlyStep = SetReadOnlyStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - setReadOnlyStep.preExecute(logger, context).execute() + setReadOnlyStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = setReadOnlyStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -55,7 +56,7 @@ class SetReadOnlyStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val setReadOnlyStep = SetReadOnlyStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - setReadOnlyStep.preExecute(logger, context).execute() + setReadOnlyStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = setReadOnlyStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -69,7 +70,7 @@ class SetReadOnlyStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val setReadOnlyStep = SetReadOnlyStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - setReadOnlyStep.preExecute(logger, context).execute() + setReadOnlyStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = setReadOnlyStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "nested", updatedManagedIndexMetaData.info!!["cause"]) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/SetReadWriteStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/SetReadWriteStepTests.kt index 77211adde..03c03818d 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/SetReadWriteStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/SetReadWriteStepTests.kt @@ -18,6 +18,7 @@ import org.opensearch.client.IndicesAdminClient import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.step.readwrite.SetReadWriteStep import org.opensearch.indexmanagement.spi.indexstatemanagement.Step import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData @@ -41,7 +42,7 @@ class SetReadWriteStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val setReadWriteStep = SetReadWriteStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - setReadWriteStep.preExecute(logger, context).execute() + setReadWriteStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = setReadWriteStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -55,7 +56,7 @@ class SetReadWriteStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val setReadWriteStep = SetReadWriteStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - setReadWriteStep.preExecute(logger, context).execute() + setReadWriteStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = setReadWriteStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) } @@ -69,7 +70,7 @@ class SetReadWriteStepTests : OpenSearchTestCase() { val managedIndexMetaData = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, null, null, null, null) val setReadWriteStep = SetReadWriteStep() val context = StepContext(managedIndexMetaData, clusterService, client, null, null, scriptService, settings, lockService) - setReadWriteStep.preExecute(logger, context).execute() + setReadWriteStep.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = setReadWriteStep.getUpdatedManagedIndexMetadata(managedIndexMetaData) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "nested", updatedManagedIndexMetaData.info!!["cause"]) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForRollupCompletionStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForRollupCompletionStepTests.kt index 8537a3b54..181d94aa5 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForRollupCompletionStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForRollupCompletionStepTests.kt @@ -10,6 +10,7 @@ import kotlinx.coroutines.runBlocking import org.opensearch.client.Client import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.step.rollup.WaitForRollupCompletionStep import org.opensearch.indexmanagement.rollup.model.RollupMetadata import org.opensearch.indexmanagement.rollup.model.RollupStats @@ -52,7 +53,7 @@ class WaitForRollupCompletionStepTests : OpenSearchTestCase() { val step = WaitForRollupCompletionStep() runBlocking { - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) } val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForSnapshotStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForSnapshotStepTests.kt index ae4d394df..a6a17f7cb 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForSnapshotStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForSnapshotStepTests.kt @@ -20,6 +20,7 @@ import org.opensearch.cluster.SnapshotsInProgress import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings import org.opensearch.core.action.ActionListener +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.action.SnapshotAction import org.opensearch.indexmanagement.indexstatemanagement.step.snapshot.WaitForSnapshotStep import org.opensearch.indexmanagement.spi.indexstatemanagement.Step @@ -50,7 +51,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, emptyActionProperties), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", WaitForSnapshotStep.getFailedActionPropertiesMessage("test", emptyActionProperties), updatedManagedIndexMetaData.info!!["message"]) @@ -62,7 +63,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, nullActionProperties), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", WaitForSnapshotStep.getFailedActionPropertiesMessage("test", nullActionProperties), updatedManagedIndexMetaData.info!!["message"]) @@ -82,7 +83,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, ActionProperties(snapshotName = "snapshot-name")), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not CONDITION_NOT_MET", Step.StepStatus.CONDITION_NOT_MET, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get snapshot in progress message", WaitForSnapshotStep.getSnapshotInProgressMessage("test"), updatedManagedIndexMetaData.info!!["message"]) @@ -94,7 +95,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, ActionProperties(snapshotName = "snapshot-name")), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not CONDITION_NOT_MET", Step.StepStatus.CONDITION_NOT_MET, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get snapshot in progress message", WaitForSnapshotStep.getSnapshotInProgressMessage("test"), updatedManagedIndexMetaData.info!!["message"]) @@ -106,7 +107,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, ActionProperties(snapshotName = "snapshot-name")), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not COMPLETED", Step.StepStatus.COMPLETED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get snapshot completed message", WaitForSnapshotStep.getSuccessMessage("test"), updatedManagedIndexMetaData.info!!["message"]) @@ -118,7 +119,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, ActionProperties(snapshotName = "snapshot-name")), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get snapshot failed message", WaitForSnapshotStep.getFailedExistsMessage("test"), updatedManagedIndexMetaData.info!!["message"]) @@ -130,7 +131,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, ActionProperties(snapshotName = "snapshot-name")), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get snapshot failed message", WaitForSnapshotStep.getFailedExistsMessage("test"), updatedManagedIndexMetaData.info!!["message"]) @@ -149,7 +150,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, ActionProperties(snapshotName = "snapshot-name")), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get snapshot failed message", WaitForSnapshotStep.getFailedExistsMessage("test"), updatedManagedIndexMetaData.info!!["message"]) @@ -164,7 +165,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, ActionProperties(snapshotName = "snapshot-name")), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "example", updatedManagedIndexMetaData.info!!["cause"]) @@ -179,7 +180,7 @@ class WaitForSnapshotStepTests : OpenSearchTestCase() { val metadata = ManagedIndexMetaData("test", "indexUuid", "policy_id", null, null, null, null, null, null, null, ActionMetaData(WaitForSnapshotStep.name, 1, 0, false, 0, null, ActionProperties(snapshotName = "snapshot-name")), null, null, null) val step = WaitForSnapshotStep(snapshotAction) val context = StepContext(metadata, clusterService, client, null, null, scriptService, settings, lockService) - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) assertEquals("Step status is not FAILED", Step.StepStatus.FAILED, updatedManagedIndexMetaData.stepMetaData?.stepStatus) assertEquals("Did not get cause from nested exception", "nested", updatedManagedIndexMetaData.info!!["cause"]) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForTransformCompletionStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForTransformCompletionStepTests.kt index bbd0bc99e..8f945cf26 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForTransformCompletionStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/WaitForTransformCompletionStepTests.kt @@ -10,6 +10,7 @@ import kotlinx.coroutines.runBlocking import org.opensearch.client.Client import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings +import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner import org.opensearch.indexmanagement.indexstatemanagement.step.transform.AttemptCreateTransformJobStep import org.opensearch.indexmanagement.indexstatemanagement.step.transform.WaitForTransformCompletionStep import org.opensearch.indexmanagement.spi.indexstatemanagement.Step @@ -71,7 +72,7 @@ class WaitForTransformCompletionStepTests : OpenSearchTestCase() { val step = WaitForTransformCompletionStep() runBlocking { - step.preExecute(logger, context).execute() + step.preExecute(logger, context).execute(ManagedIndexRunner.indexManagementActionMetrics) } val updatedManagedIndexMetaData = step.getUpdatedManagedIndexMetadata(metadata) From 9eaf83a605f3e88bfbc9c9ff9d741fd177e83bf1 Mon Sep 17 00:00:00 2001 From: harycash Date: Thu, 13 Jun 2024 11:14:13 +0530 Subject: [PATCH 4/4] Initial integration of TelemetryAwarePlugin to ISM with Rollover Step Integration Signed-off-by: harycash --- .../step/rollover/AttemptRolloverStep.kt | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) 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 fb8f40d56..16c5c64d2 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 @@ -75,7 +75,11 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { if (!isDataStream && !preCheckIndexAlias(context, rolloverTarget)) { stepStatus = StepStatus.FAILED info = mapOf("message" to getFailedPreCheckMessage(indexName)) - actionMetrics.failures.add(1.0, Tags.create().addTag("index_name", context.metadata.index).addTag("policy_id", context.metadata.policyID).addTag("node_id", context.clusterService.nodeName)) + actionMetrics.failures.add( + 1.0, + Tags.create().addTag("index_name", context.metadata.index) + .addTag("policy_id", context.metadata.policyID).addTag("node_id", context.clusterService.nodeName), + ) return this } @@ -163,7 +167,11 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { logger.warn(message) stepStatus = StepStatus.FAILED info = mapOf("message" to message) - actionMetrics.failures.add(1.0, Tags.create().addTag("index_name", context.metadata.index).addTag("policy_id", context.metadata.policyID).addTag("node_id", context.clusterService.nodeName)) + actionMetrics.failures.add( + 1.0, + Tags.create().addTag("index_name", context.metadata.index) + .addTag("policy_id", context.metadata.policyID).addTag("node_id", context.clusterService.nodeName), + ) } return rolloverTarget to isDataStreamIndex @@ -220,7 +228,11 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { "message" to message, "shard_failures" to statsResponse.shardFailures.map { it.getUsefulCauseString() }, ) - actionMetrics.failures.add(1.0, Tags.create().addTag("index_name", context.metadata.index).addTag("policy_id", context.metadata.policyID).addTag("node_id", context.clusterService.nodeName)) + actionMetrics.failures.add( + 1.0, + Tags.create().addTag("index_name", context.metadata.index) + .addTag("policy_id", context.metadata.policyID).addTag("node_id", context.clusterService.nodeName), + ) } catch (e: RemoteTransportException) { handleException(indexName, ExceptionsHelper.unwrapCause(e) as Exception) } catch (e: Exception) { @@ -320,7 +332,11 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { "message" to getCopyAliasRolledOverIndexNotFoundMessage(indexName), if (conditions != null) "conditions" to conditions else null, ).toMap() - actionMetrics.successes.add(1.0, Tags.create().addTag("index_name", context?.metadata?.index).addTag("policy_id", context?.metadata?.policyID).addTag("node_id", context?.clusterService?.nodeName)) + actionMetrics.successes.add( + 1.0, + Tags.create().addTag("index_name", context?.metadata?.index) + .addTag("policy_id", context?.metadata?.policyID).addTag("node_id", context?.clusterService?.nodeName), + ) return } @@ -348,7 +364,11 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { val aliasRes: AcknowledgedResponse = client.admin().indices().suspendUntil { aliases(aliasReq, it) } if (aliasRes.isAcknowledged) { stepStatus = StepStatus.COMPLETED - actionMetrics.successes.add(1.0, Tags.create().addTag("index_name", context?.metadata?.index).addTag("policy_id", context?.metadata?.policyID).addTag("node_id", context?.clusterService?.nodeName)) + actionMetrics.successes.add( + 1.0, + Tags.create().addTag("index_name", context?.metadata?.index) + .addTag("policy_id", context?.metadata?.policyID).addTag("node_id", context?.clusterService?.nodeName), + ) info = listOfNotNull( "message" to getSuccessCopyAliasMessage(indexName, rolledOverIndexName), @@ -356,7 +376,11 @@ class AttemptRolloverStep(private val action: RolloverAction) : Step(name) { ).toMap() } else { stepStatus = StepStatus.FAILED - actionMetrics.failures.add(1.0, Tags.create().addTag("index_name", context?.metadata?.index).addTag("policy_id", context?.metadata?.policyID).addTag("node_id", context?.clusterService?.nodeName)) + actionMetrics.failures.add( + 1.0, + Tags.create().addTag("index_name", context?.metadata?.index) + .addTag("policy_id", context?.metadata?.policyID).addTag("node_id", context?.clusterService?.nodeName), + ) info = listOfNotNull( "message" to getCopyAliasNotAckMessage(indexName, rolledOverIndexName),