How opensearch-project/index-management works
Purpose and runtime
This is a Kotlin/Gradle OpenSearch server plugin for index lifecycle and data-management automation. It runs in OpenSearch nodes, exposes REST and transport actions, persists operational metadata in OpenSearch indices, and schedules background jobs through the Job Scheduler SPI. Build/module entry points are build.gradle, settings.gradle, and spi/build.gradle.
Plugin composition and bootstrap
IndexManagementPlugin is the primary OpenSearch plugin registration point; it wires REST handlers, transport actions, settings, action filters/interceptors, and feature runners. IndexManagementRunner is the scheduler-extension entry point, registered through the Java service descriptor.
• src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt
• src/main/kotlin/org/opensearch/indexmanagement/IndexManagementRunner.kt
• src/main/resources/META-INF/services/org.opensearch.jobscheduler.spi.JobSchedulerExtension
Shared SPI boundary
The spi Gradle module defines extension contracts and common ISM execution abstractions. It separates pluggable action parsing, metadata access, action execution steps, validation/status checks, and action metrics from the concrete plugin implementation. External extensions can implement IndexManagementExtension and contribute ISM behavior.
• spi/src/main/kotlin/org.opensearch.indexmanagement.spi/IndexManagementExtension.kt
• spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Action.kt
• spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Step.kt
Index State Management (ISM)
ISM is the central lifecycle engine. Policies model states, actions, transitions, templates, retries, and managed-index configuration. REST handlers delegate to OpenSearch transport actions for policy CRUD, attachment/removal, simulation, explain, and retry. Policies are parsed into concrete actions, validated, then executed as resumable steps.
• src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/Policy.kt
• src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt
• src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt
ISM control flow and persistence
The coordinator discovers/sweeps managed indices; the runner loads persisted metadata, selects the current state/action/step, invokes OpenSearch operations, records progress/errors/history, and retries or transitions according to policy. Step implementations encapsulate asynchronous attempt/wait boundaries for operations such as rollover, shrink, snapshots, rollups, and transforms. ISM config/history mappings establish the persisted storage boundary.
• src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/IndexStateManagementHistory.kt
• src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt
• src/main/resources/mappings/opendistro-ism-config.json
Rollup and transform jobs
Rollup and transform are independently managed scheduled workloads with REST/transport CRUD and lifecycle controls. Their runners execute search/aggregation/indexing pipelines, while metadata services persist job state. ISM actions can create and wait for these jobs, coupling lifecycle policy execution to their completion.
• src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupRunner.kt
• src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupIndexer.kt
• src/main/kotlin/org/opensearch/indexmanagement/transform/TransformRunner.kt
• src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt
Snapshot management and operational integrations
Snapshot Management uses a dedicated policy state machine for snapshot creation and deletion, controlled through REST/transport APIs and run by SMRunner. Notifications support ISM destinations including Slack, Chime, and custom webhooks. Control Center notification filters observe index-operation responses and emit long-running-operation notifications. All integrations execute from within the OpenSearch plugin/security context.
• src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/SMRunner.kt
• src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/engine/SMStateMachine.kt
• src/main/kotlin/org/opensearch/indexmanagement/controlcenter/notification/filter/IndexOperationActionFilter.kt
Main entry points: IndexManagementRunner.kt IndexManagementRunner · IndexManagementPlugin.kt IndexManagementPlugin · ManagedIndexRunner.kt ManagedIndexRunner · AttemptRolloverStep.kt Resumable ISM steps
Components 18
OpenSearch plugin runtime
- OpenSearch node · Hosts plugin APIs, storage, and scheduler.
- IndexManagementPlugin · Registers REST, transport, settings, filters, and feature runners.
src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt - Job Scheduler service entry
src/main/resources/META-INF/services/org.opensearch.jobscheduler.spi.JobSchedulerExtension - IndexManagementRunner · Starts plugin-managed scheduled features.
src/main/kotlin/org/opensearch/indexmanagement/IndexManagementRunner.kt - Shared SPI contracts · Extension and ISM execution contracts for external contributors.
spi/src/main/kotlin/org.opensearch.indexmanagement.spi/IndexManagementExtension.kt - IndexOperationActionFilter · Emits Control Center notifications for long-running index operations.
src/main/kotlin/org/opensearch/indexmanagement/controlcenter/notification/filter/IndexOperationActionFilter.kt
Index State Management
- ISM REST and transport APIs · Policy CRUD, attachment, simulation, explain, and retry operations.
- ISM policy model · Defines states, actions, transitions, templates, and retries.
src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/Policy.kt - ManagedIndexCoordinator · Discovers managed indices and schedules their work.
src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt - ManagedIndexRunner · Resumes policy action steps and records outcomes.
src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt - Resumable ISM steps · Attempt/wait boundaries for OpenSearch operations.
src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt - ISM config and history · Persists managed-index metadata, progress, errors, and history.
src/main/resources/mappings/opendistro-ism-config.json
Scheduled workloads
- RollupRunner · Controls rollup job execution.
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupRunner.kt - RollupIndexer · Searches, aggregates, and indexes rollup output.
src/main/kotlin/org/opensearch/indexmanagement/rollup/RollupIndexer.kt - TransformRunner · Controls transform job execution.
src/main/kotlin/org/opensearch/indexmanagement/transform/TransformRunner.kt - TransformIndexer · Executes transform search and indexing work.
src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt - SMRunner · Runs snapshot-management policies.
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/SMRunner.kt - SMStateMachine · Drives snapshot creation and deletion states.
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/engine/SMStateMachine.kt
Connections 23
- OpenSearch node → IndexManagementPlugin: loads
- IndexManagementPlugin → ISM REST and transport APIs: registers
- IndexManagementPlugin → IndexManagementRunner: wires features
- Job Scheduler service entry → IndexManagementRunner: registers
- IndexManagementPlugin → Shared SPI contracts: uses extension contracts
- ISM REST and transport APIs → ISM policy model: manages
- ISM REST and transport APIs → ISM config and history: persists metadata
- IndexManagementRunner → ManagedIndexCoordinator: schedules
- ManagedIndexCoordinator → ManagedIndexRunner: dispatches indices
- ManagedIndexRunner → ISM policy model: evaluates
- ManagedIndexRunner → Resumable ISM steps: executes
- ManagedIndexRunner → ISM config and history: loads and records state
- Resumable ISM steps → OpenSearch node: invokes operations
- IndexManagementRunner → RollupRunner: schedules
- RollupRunner → RollupIndexer: executes
- IndexManagementRunner → TransformRunner: schedules
- TransformRunner → TransformIndexer: executes
- IndexManagementRunner → SMRunner: schedules
- SMRunner → SMStateMachine: drives
- Resumable ISM steps → RollupRunner: creates or waits for jobs
- Resumable ISM steps → TransformRunner: creates or waits for jobs
- IndexManagementPlugin → IndexOperationActionFilter: registers
- IndexOperationActionFilter → OpenSearch node: observes index responses