Skip to content

Commit 35b80e0

Browse files
jowg-amazonpetardzAngie-Zhangstevanbzxluo-aws
authored
Action Validation framework and Explain API integration (#441)
* initial framework Signed-off-by: Joanne Wang <jowg@amazon.com> * Removed recursion from Explain Action to avoid stackoverflow in some situations (#419) Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> Signed-off-by: Joanne Wang <jowg@amazon.com> * enabled by default integrated Signed-off-by: Joanne Wang <jowg@amazon.com> * cleaned up comments and logs, created unit test and updated previous integration tests Signed-off-by: Joanne Wang <jowg@amazon.com> * added delete validation logic Signed-off-by: Joanne Wang <jowg@amazon.com> * fixed rollover validation unit tests Signed-off-by: Joanne Wang <jowg@amazon.com> * added validation info field to ManagedIndexMetaData Signed-off-by: Joanne Wang <jowg@amazon.com> * removed step context as input Signed-off-by: Joanne Wang <jowg@amazon.com> * added validationmetadata class Signed-off-by: Joanne Wang <jowg@amazon.com> * restored old integration tests and changed validation service output Signed-off-by: Joanne Wang <jowg@amazon.com> * before integrated validation meta data into managed index meta data Signed-off-by: Joanne Wang <jowg@amazon.com> * integrated validation meta data Signed-off-by: Joanne Wang <jowg@amazon.com> * working version Signed-off-by: Joanne Wang <jowg@amazon.com> * added validation mapping Signed-off-by: Joanne Wang <jowg@amazon.com> * fixed integ tests Signed-off-by: Joanne Wang <jowg@amazon.com> * renamed some values Signed-off-by: Joanne Wang <jowg@amazon.com> * before removing from managed index meta data Signed-off-by: Joanne Wang <jowg@amazon.com> * created validation result object in explain Signed-off-by: Joanne Wang <jowg@amazon.com> * testing Signed-off-by: Joanne Wang <jowg@amazon.com> * run fails Signed-off-by: Joanne Wang <jowg@amazon.com> * integration test for delete + added framework for force merge Signed-off-by: Joanne Wang <jowg@amazon.com> * removed step validation metadata and still testing explain results Signed-off-by: Joanne Wang <jowg@amazon.com> * before removing from managed index runner Signed-off-by: Joanne Wang <jowg@amazon.com> * removed from managed index runner Signed-off-by: Joanne Wang <jowg@amazon.com> * clean up and tests Signed-off-by: Joanne Wang <jowg@amazon.com> * all validation tests pass Signed-off-by: Joanne Wang <jowg@amazon.com> * removed validation result from all managed index meta data Signed-off-by: Joanne Wang <jowg@amazon.com> * restored old IT tests Signed-off-by: Joanne Wang <jowg@amazon.com> * fixed it tests, set explain validation to false Signed-off-by: Joanne Wang <jowg@amazon.com> * clean up Signed-off-by: Joanne Wang <jowg@amazon.com> * Change test page size to avoid index/search TimeInMillis < 1 issue. (#460) * Change test page size to avoid indexTimeInMillis < 1 issue. Signed-off-by: Angie Zhang <langelzh@amazon.com> * Change test page size to avoid indexTimeInMillis < 1 issue. Signed-off-by: Angie Zhang <langelzh@amazon.com> Signed-off-by: Angie Zhang <langelzh@amazon.com> * Transform maxclauses fix (#477) * transform maxClauses fix Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> * added bucket log to track processed buckets Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> * various renames/changes Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> * fixed detekt issues Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> * added comments to test Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> * removed debug logging Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> * empty commit to trigger checks Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> * reduced pageSize to 1 in few ITs to avoid flaky tests; fixed bug where pagesProcessed was calculated incorrectly Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> * reverted pagesProcessed change; fixed few ITs Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> * 483: Updated detekt plugin and snakeyaml dependency. Updated a code t… (#485) * 483: Updated detekt plugin and snakeyaml dependency. Updated a code to reduce the number of issues after static analysis Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> * 483: Updated snakeyaml version to use the latest Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> * Remove HOST_DENY_LIST usage as Notification plugin will own it (#471) (#107) Signed-off-by: Xuesong Luo <lxuesong@amazon.com> Signed-off-by: Xuesong Luo <lxuesong@amazon.com> * Disable detekt because of the CVE (#497) Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * Deprecate Master nonmenclature (#501) Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> * [AUTO] Increment version to 2.3.0-SNAPSHOT (#484) (#503) * fix#921-README-forum-link-index_mgmnt (#499) Signed-off-by: cwillum <cwmmoore@amazon.com> Signed-off-by: cwillum <cwmmoore@amazon.com> * 64: Added rounding when using aggreagate script for avg metric. Added… (#490) * 64: Added rounding when using aggreagate script for avg metric. Added unit tests for checking average aggregations against the target rollup index Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> * 64: Rollup job renamed Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> * 64: Removed unrelevant metrics for the avg calculation test Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> * Revert Disable detekt and force choose snakeyml 1.32 (#528) * Revert Disable detekt: 50ac1e9 Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com> * Remove force choosing snakeyml 1.31 Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com> * Force snakeyaml 1.32 Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com> * Empty commit Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com> Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com> * Added 2.3 release note (#507) (#515) (#517) * Update 2.3 release note Signed-off-by: Angie Zhang <langelzh@amazon.com> * Update 2.3 release note Signed-off-by: Angie Zhang <langelzh@amazon.com> * Update 2.3 release note Signed-off-by: Angie Zhang <langelzh@amazon.com> * Update 2.3 release note Signed-off-by: Angie Zhang <langelzh@amazon.com> * Update 2.3 release note Signed-off-by: Angie Zhang <langelzh@amazon.com> Signed-off-by: Angie Zhang <langelzh@amazon.com> (cherry picked from commit d9793ac) Signed-off-by: Angie Zhang <langelzh@amazon.com> Signed-off-by: Angie Zhang <langelzh@amazon.com> (cherry picked from commit 7217b5b) Co-authored-by: Angie Zhang <langelzh@amazon.com> * Add 2.2 release note (#450) (#452) (#516) * Add 2.2 release note Signed-off-by: Angie Zhang <langelzh@amazon.com> * Add 2.2 release note Signed-off-by: Angie Zhang <langelzh@amazon.com> Co-authored-by: Angie Zhang <langelzh@amazon.com> (cherry picked from commit 8eb5da6) Signed-off-by: Angie Zhang <langelzh@amazon.com> Signed-off-by: Angie Zhang <langelzh@amazon.com> Co-authored-by: Ashish Agrawal <ashisagr@amazon.com> * Adds plugin version sweep background job (#434) * [207]: Added 5 min scheduled job for sweeping ISM plugin version in the case of version discrepancy Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> * [207]: Created pluginVersionSweepCoordinator component responsible for scheduling the skip execution task. Annotated tests in order to prevent thread leak error during integrational tests Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> * [207]: Increased retry period for background job that sets the skip flag up to 5 mins Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> * Empty-Commit Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> Co-authored-by: Stevan Buzejic <buzejic.stevan@gmail.com> * flaky transform test fix attempt (#542) * flaky transform test fix attempt Signed-off-by: Petar Dzepina <petar.dzepina@vroom.com> * accidental paste fix Signed-off-by: Petar Dzepina <petar.dzepina@vroom.com> Signed-off-by: Petar Dzepina <petar.dzepina@vroom.com> Co-authored-by: Petar Dzepina <petar.dzepina@vroom.com> Signed-off-by: Joanne Wang <jowg@amazon.com> Signed-off-by: Petar Dzepina <petar.dzepina@gmail.com> Signed-off-by: Angie Zhang <langelzh@amazon.com> Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com> Signed-off-by: Xuesong Luo <lxuesong@amazon.com> Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com> Signed-off-by: cwillum <cwmmoore@amazon.com> Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com> Signed-off-by: Petar Dzepina <petar.dzepina@vroom.com> Co-authored-by: Petar <petar.dzepina@gmail.com> Co-authored-by: Angie Zhang <98716549+Angie-Zhang@users.noreply.github.com> Co-authored-by: Stevan Buzejic <30922513+stevanbz@users.noreply.github.com> Co-authored-by: xluo-aws <109580118+xluo-aws@users.noreply.github.com> Co-authored-by: bowenlan-amzn <bowenlan23@gmail.com> Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Co-authored-by: Chris Moore <107723039+cwillum@users.noreply.github.com> Co-authored-by: Siddhant Deshmukh <deshsid@amazon.com> Co-authored-by: Angie Zhang <langelzh@amazon.com> Co-authored-by: Ashish Agrawal <ashisagr@amazon.com> Co-authored-by: Clay Downs <downsrob@amazon.com> Co-authored-by: Stevan Buzejic <buzejic.stevan@gmail.com> Co-authored-by: Petar Dzepina <petar.dzepina@vroom.com>
1 parent 2f7d009 commit 35b80e0

File tree

68 files changed

+1867
-162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1867
-162
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![codecov](https://codecov.io/gh/opensearch-project/index-management/branch/main/graph/badge.svg)](https://codecov.io/gh/opensearch-project/index-management)
33
[![Roadmap](https://img.shields.io/badge/roadmap-checkout-ff69b4)](https://github.com/opensearch-project/index-management/projects/1)
44
[![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://opensearch.org/docs/im-plugin/index/)
5-
[![Chat](https://img.shields.io/badge/chat-on%20forums-blue)](https://discuss.opendistrocommunity.dev/c/index-management/)
5+
[![Chat](https://img.shields.io/badge/chat-on%20forums-blue)](https://forum.opensearch.org/c/plugins/index-management/47)
66
![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success)
77

88
<img src="https://opensearch.org/assets/brand/SVG/Logo/opensearch_logo_default.svg" height="64px"/>
@@ -59,7 +59,7 @@ See [developer guide](DEVELOPER_GUIDE.md) and [how to contribute to this project
5959

6060
If you find a bug, or have a feature request, please don't hesitate to open an issue in this repository.
6161

62-
For more information, see [project website](https://opensearch.org/) and [documentation](https://opensearch.org/docs/). If you need help and are unsure where to open an issue, try [forums](https://discuss.opendistrocommunity.dev/).
62+
For more information, see [project website](https://opensearch.org/) and [documentation](https://opensearch.org/docs/latest/im-plugin/index/). If you need help and are unsure where to open an issue, try [Forum](https://forum.opensearch.org/c/plugins/index-management/47).
6363

6464
## Code of Conduct
6565

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import java.util.function.Predicate
1414
buildscript {
1515
ext {
1616
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
17-
opensearch_version = System.getProperty("opensearch.version", "2.2.0-SNAPSHOT")
17+
opensearch_version = System.getProperty("opensearch.version", "2.3.0-SNAPSHOT")
1818
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
1919
// 2.2.0-SNAPSHOT -> 2.2.0.0-SNAPSHOT
2020
version_tokens = opensearch_version.tokenize('-')
@@ -59,7 +59,7 @@ buildscript {
5959
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
6060
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
6161
classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}"
62-
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.17.1"
62+
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0"
6363
classpath "org.jacoco:org.jacoco.agent:0.8.7"
6464
}
6565
}
@@ -95,7 +95,7 @@ configurations.all {
9595
force 'org.apache.httpcomponents.client5:httpclient5:5.0.3'
9696
force 'org.apache.httpcomponents.client5:httpclient5-osgi:5.0.3'
9797
force 'com.fasterxml.jackson.core:jackson-databind:2.10.4'
98-
force 'org.yaml:snakeyaml:1.26'
98+
force 'org.yaml:snakeyaml:1.32'
9999
force 'org.codehaus.plexus:plexus-utils:3.0.24'
100100
}
101101
}
@@ -180,12 +180,12 @@ dependencies {
180180
implementation "com.github.seancfoley:ipaddress:5.3.3"
181181
implementation "commons-codec:commons-codec:${versions.commonscodec}"
182182
implementation "org.apache.httpcomponents:httpclient:4.5.13"
183-
implementation "org.apache.httpcomponents:httpcore:4.4.12"
183+
implementation "org.apache.httpcomponents:httpcore:4.4.15"
184184

185185
testImplementation "org.opensearch.test:framework:${opensearch_version}"
186186
testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}"
187187
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
188-
testImplementation "org.mockito:mockito-core:4.6.1"
188+
testImplementation "org.mockito:mockito-core:4.7.0"
189189

190190
add("ktlint", "com.pinterest:ktlint:0.45.1") {
191191
attributes {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Version 2.2.0.0 2022-08-05
2+
3+
Compatible with OpenSearch 2.2.0
4+
5+
### Features
6+
* Ability to count the number of documents from source index ([#439](https://github.com/opensearch-project/index-management/pull/439)) and ([#3985](https://github.com/opensearch-project/OpenSearch/pull/3985))
7+
8+
### Enhancements
9+
* Support mustache scripting of rollup.target_index field ([#435](https://github.com/opensearch-project/index-management/pull/435))
10+
* Support searching multiple rollup indices with same mapping ([#440](https://github.com/opensearch-project/index-management/pull/440))
11+
12+
### Maintenance
13+
* version upgrade to 2.2.0 ([#446](https://github.com/opensearch-project/index-management/pull/446))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Version 2.3.0.0 2022-09-09
2+
3+
Compatible with OpenSearch 2.3.0
4+
5+
### Enhancements
6+
* Replica Count Validation when awareness replica balance is enabled ([#429](https://github.com/opensearch-project/index-management/pull/429))
7+
* Updated detekt plugin, snakeyaml dependency and code to reduce the number of issues after static analysis ([#483](https://github.com/opensearch-project/index-management/pull/483))
8+
* Transform max_clauses optimization: limit amount of modified buckets being processed at a time and added capping of pageSize to avoid maxClause exception ([#477](https://github.com/opensearch-project/index-management/pull/477))
9+
* Remove HOST_DENY_LIST usage as Notification plugin will own it ([#488](https://github.com/opensearch-project/index-management/pull/488))
10+
* Deprecate Master nonmenclature ([#502](https://github.com/opensearch-project/index-management/pull/502))
11+
12+
### Bug Fixes
13+
* Failed concurrent creates of ISM policies should return http 409 ([#464](https://github.com/opensearch-project/index-management/pull/464))
14+
* Disable detekt to avoid the CVE issues ([#500](https://github.com/opensearch-project/index-management/pull/500))
15+
16+
### Infrastructure
17+
* Staging for version increment automation ([#409](https://github.com/opensearch-project/index-management/pull/409))
18+
19+
### Maintenance
20+
* Version upgrade to 2.3.0 ([#484](https://github.com/opensearch-project/index-management/pull/484))
21+
22+
### Documentation
23+
* Added 2.3 release note ([#507](https://github.com/opensearch-project/index-management/pull/507))
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.indexmanagement.spi.indexstatemanagement
7+
8+
import org.opensearch.cluster.service.ClusterService
9+
import org.opensearch.common.io.stream.StreamInput
10+
import org.opensearch.common.io.stream.StreamOutput
11+
import org.opensearch.common.io.stream.Writeable
12+
import org.opensearch.common.settings.Settings
13+
import org.opensearch.monitor.jvm.JvmService
14+
import java.util.Locale
15+
16+
abstract class Validate(
17+
val settings: Settings,
18+
val clusterService: ClusterService,
19+
val jvmService: JvmService
20+
) {
21+
22+
var validationStatus = ValidationStatus.PASSED
23+
var validationMessage: String? = "Starting Validation"
24+
25+
abstract fun execute(indexName: String): Validate
26+
27+
enum class ValidationStatus(val status: String) : Writeable {
28+
PASSED("passed"),
29+
RE_VALIDATING("re_validating"),
30+
FAILED("failed");
31+
32+
override fun toString(): String {
33+
return status
34+
}
35+
36+
override fun writeTo(out: StreamOutput) {
37+
out.writeString(status)
38+
}
39+
40+
companion object {
41+
fun read(streamInput: StreamInput): ValidationStatus {
42+
return valueOf(streamInput.readString().uppercase(Locale.ROOT))
43+
}
44+
}
45+
}
46+
}

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/model/ManagedIndexMetaData.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ data class ManagedIndexMetaData(
241241
var action: ActionMetaData? = null
242242
var step: StepMetaData? = null
243243
var retryInfo: PolicyRetryInfoMetaData? = null
244-
245244
var info: Map<String, Any>? = null
246245

247246
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.currentToken(), xcp)
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.indexmanagement.spi.indexstatemanagement.model
7+
8+
import org.opensearch.common.Strings
9+
import org.opensearch.common.io.stream.StreamInput
10+
import org.opensearch.common.io.stream.StreamOutput
11+
import org.opensearch.common.io.stream.Writeable
12+
import org.opensearch.common.xcontent.LoggingDeprecationHandler
13+
import org.opensearch.common.xcontent.NamedXContentRegistry
14+
import org.opensearch.common.xcontent.ToXContent
15+
import org.opensearch.common.xcontent.ToXContentFragment
16+
import org.opensearch.common.xcontent.XContentBuilder
17+
import org.opensearch.common.xcontent.XContentParser
18+
import org.opensearch.common.xcontent.XContentParserUtils
19+
import org.opensearch.common.xcontent.XContentType
20+
import org.opensearch.indexmanagement.spi.indexstatemanagement.Validate
21+
import java.io.ByteArrayInputStream
22+
import java.nio.charset.StandardCharsets
23+
import java.util.Locale
24+
25+
data class ValidationResult(
26+
val validationMessage: String,
27+
val validationStatus: Validate.ValidationStatus
28+
) : Writeable, ToXContentFragment {
29+
30+
override fun writeTo(out: StreamOutput) {
31+
out.writeString(validationMessage)
32+
validationStatus.writeTo(out)
33+
}
34+
35+
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder {
36+
builder
37+
.field(VALIDATION_MESSAGE, validationMessage)
38+
.field(VALIDATION_STATUS, validationStatus.toString())
39+
return builder
40+
}
41+
42+
fun getMapValueString(): String {
43+
return Strings.toString(this, false, false)
44+
}
45+
46+
companion object {
47+
const val VALIDATE = "validate"
48+
const val VALIDATION_MESSAGE = "validation_message"
49+
const val VALIDATION_STATUS = "validation_status"
50+
51+
fun fromStreamInput(si: StreamInput): ValidationResult {
52+
val validationMessage: String? = si.readString()
53+
val validationStatus: Validate.ValidationStatus? = Validate.ValidationStatus.read(si)
54+
55+
return ValidationResult(
56+
requireNotNull(validationMessage) { "$VALIDATION_MESSAGE is null" },
57+
requireNotNull(validationStatus) { "$VALIDATION_STATUS is null" }
58+
)
59+
}
60+
61+
fun fromManagedIndexMetaDataMap(map: Map<String, String?>): ValidationResult? {
62+
val stepJsonString = map[VALIDATE]
63+
return if (stepJsonString != null) {
64+
val inputStream = ByteArrayInputStream(stepJsonString.toByteArray(StandardCharsets.UTF_8))
65+
val parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, inputStream)
66+
parser.nextToken()
67+
parse(parser)
68+
} else {
69+
null
70+
}
71+
}
72+
73+
fun parse(xcp: XContentParser): ValidationResult {
74+
var validationMessage: String? = null
75+
var validationStatus: Validate.ValidationStatus? = null
76+
77+
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.currentToken(), xcp)
78+
while (xcp.nextToken() != XContentParser.Token.END_OBJECT) {
79+
val fieldName = xcp.currentName()
80+
xcp.nextToken()
81+
82+
when (fieldName) {
83+
VALIDATION_MESSAGE -> validationMessage = xcp.text()
84+
VALIDATION_STATUS -> validationStatus = Validate.ValidationStatus.valueOf(xcp.text().uppercase(Locale.ROOT))
85+
}
86+
}
87+
88+
return ValidationResult(
89+
requireNotNull(validationMessage) { "$VALIDATION_MESSAGE is null" },
90+
requireNotNull(validationStatus) { "$VALIDATION_STATUS is null" }
91+
)
92+
}
93+
}
94+
}

src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.IndexStateManagementH
3737
import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexCoordinator
3838
import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner
3939
import org.opensearch.indexmanagement.indexstatemanagement.MetadataService
40+
import org.opensearch.indexmanagement.indexstatemanagement.PluginVersionSweepCoordinator
4041
import org.opensearch.indexmanagement.indexstatemanagement.SkipExecution
4142
import org.opensearch.indexmanagement.indexstatemanagement.model.ManagedIndexConfig
4243
import org.opensearch.indexmanagement.indexstatemanagement.model.Policy
@@ -73,7 +74,8 @@ import org.opensearch.indexmanagement.indexstatemanagement.transport.action.retr
7374
import org.opensearch.indexmanagement.indexstatemanagement.transport.action.updateindexmetadata.TransportUpdateManagedIndexMetaDataAction
7475
import org.opensearch.indexmanagement.indexstatemanagement.transport.action.updateindexmetadata.UpdateManagedIndexMetaDataAction
7576
import org.opensearch.indexmanagement.indexstatemanagement.util.DEFAULT_INDEX_TYPE
76-
import org.opensearch.indexmanagement.migration.ISMTemplateService
77+
import org.opensearch.indexmanagement.indexstatemanagement.validation.ValidationService
78+
import org.opensearch.indexmanagement.indexstatemanagement.migration.ISMTemplateService
7779
import org.opensearch.indexmanagement.refreshanalyzer.RefreshSearchAnalyzerAction
7880
import org.opensearch.indexmanagement.refreshanalyzer.RestRefreshSearchAnalyzerAction
7981
import org.opensearch.indexmanagement.refreshanalyzer.TransportRefreshSearchAnalyzerAction
@@ -186,6 +188,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin
186188

187189
private val logger = LogManager.getLogger(javaClass)
188190
lateinit var indexManagementIndices: IndexManagementIndices
191+
lateinit var validationService: ValidationService
189192
lateinit var clusterService: ClusterService
190193
lateinit var indexNameExpressionResolver: IndexNameExpressionResolver
191194
lateinit var rollupInterceptor: RollupInterceptor
@@ -280,15 +283,15 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin
280283
indexManagementExtensions.forEach { extension ->
281284
val extensionName = extension.getExtensionName()
282285
if (extensionName in extensions) {
283-
throw IllegalStateException("Multiple extensions of IndexManagement have same name $extensionName - not supported")
286+
error("Multiple extensions of IndexManagement have same name $extensionName - not supported")
284287
}
285288
extension.getISMActionParsers().forEach { parser ->
286289
ISMActionsParser.instance.addParser(parser, extensionName)
287290
}
288291
indexMetadataServices.add(extension.getIndexMetadataService())
289292
extension.overrideClusterStateIndexUuidSetting()?.let {
290293
if (customIndexUUIDSetting != null) {
291-
throw IllegalStateException(
294+
error(
292295
"Multiple extensions of IndexManagement plugin overriding ClusterStateIndexUUIDSetting - not supported"
293296
)
294297
}
@@ -364,13 +367,13 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin
364367
xContentRegistry,
365368
settings,
366369
indexNameExpressionResolver,
367-
jvmService,
370+
jvmService, // put jvm
368371
threadPool
369372
)
370373
fieldCapsFilter = FieldCapsFilter(clusterService, settings, indexNameExpressionResolver)
371374
this.indexNameExpressionResolver = indexNameExpressionResolver
372375

373-
val skipFlag = SkipExecution(client, clusterService)
376+
val skipFlag = SkipExecution(client)
374377
RollupFieldValueExpressionResolver.registerScriptService(scriptService)
375378
val rollupRunner = RollupRunner
376379
.registerClient(client)
@@ -386,6 +389,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin
386389
.registerConsumers()
387390
.registerClusterConfigurationProvider(skipFlag)
388391
indexManagementIndices = IndexManagementIndices(settings, client.admin().indices(), clusterService)
392+
validationService = ValidationService(settings, clusterService, jvmService)
389393
val indexStateManagementHistory =
390394
IndexStateManagementHistory(
391395
settings,
@@ -407,6 +411,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin
407411
val managedIndexRunner = ManagedIndexRunner
408412
.registerClient(client)
409413
.registerClusterService(clusterService)
414+
.registerValidationService(validationService)
410415
.registerNamedXContentRegistry(xContentRegistry)
411416
.registerScriptService(scriptService)
412417
.registerSettings(settings)
@@ -428,15 +433,19 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin
428433

429434
val smRunner = SMRunner.init(client, threadPool, settings, indexManagementIndices, clusterService)
430435

436+
val pluginVersionSweepCoordinator = PluginVersionSweepCoordinator(skipFlag, settings, threadPool, clusterService)
437+
431438
return listOf(
432439
managedIndexRunner,
433440
rollupRunner,
434441
transformRunner,
435442
indexManagementIndices,
443+
validationService,
436444
managedIndexCoordinator,
437445
indexStateManagementHistory,
438446
indexMetadataProvider,
439-
smRunner
447+
smRunner,
448+
pluginVersionSweepCoordinator
440449
)
441450
}
442451

@@ -454,13 +463,15 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin
454463
ManagedIndexSettings.ROLLOVER_ALIAS,
455464
ManagedIndexSettings.ROLLOVER_SKIP,
456465
ManagedIndexSettings.INDEX_STATE_MANAGEMENT_ENABLED,
466+
ManagedIndexSettings.VALIDATION_SERVICE_ENABLED,
457467
ManagedIndexSettings.METADATA_SERVICE_ENABLED,
458468
ManagedIndexSettings.AUTO_MANAGE,
459469
ManagedIndexSettings.METADATA_SERVICE_STATUS,
460470
ManagedIndexSettings.TEMPLATE_MIGRATION_CONTROL,
461471
ManagedIndexSettings.JITTER,
462472
ManagedIndexSettings.JOB_INTERVAL,
463473
ManagedIndexSettings.SWEEP_PERIOD,
474+
ManagedIndexSettings.SWEEP_SKIP_PERIOD,
464475
ManagedIndexSettings.COORDINATOR_BACKOFF_COUNT,
465476
ManagedIndexSettings.COORDINATOR_BACKOFF_MILLIS,
466477
ManagedIndexSettings.ALLOW_LIST,

src/main/kotlin/org/opensearch/indexmanagement/common/model/notification/Channel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ data class Channel(val id: String) : ToXContent, Writeable {
6161
when (fieldName) {
6262
ID -> id = xcp.text()
6363
else -> {
64-
throw IllegalStateException("Unexpected field: $fieldName, while parsing Channel destination")
64+
error("Unexpected field: $fieldName, while parsing Channel destination")
6565
}
6666
}
6767
}

src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.util.isFailed
7373
import org.opensearch.indexmanagement.indexstatemanagement.util.isPolicyCompleted
7474
import org.opensearch.indexmanagement.indexstatemanagement.util.managedIndexConfigIndexRequest
7575
import org.opensearch.indexmanagement.indexstatemanagement.util.updateEnableManagedIndexRequest
76-
import org.opensearch.indexmanagement.migration.ISMTemplateService
76+
import org.opensearch.indexmanagement.indexstatemanagement.migration.ISMTemplateService
7777
import org.opensearch.indexmanagement.opensearchapi.IndexManagementSecurityContext
7878
import org.opensearch.indexmanagement.opensearchapi.contentParser
7979
import org.opensearch.indexmanagement.opensearchapi.parseFromSearchResponse

0 commit comments

Comments
 (0)