Skip to content

Commit 274ffb7

Browse files
authored
Merge branch 'main' into patch-1
2 parents e8a6df6 + 75d5e1f commit 274ffb7

File tree

77 files changed

+415
-20
lines changed

Some content is hidden

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

77 files changed

+415
-20
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ dependencies {
239239
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
240240
testImplementation "org.mockito:mockito-core:${versions.mockito}"
241241

242-
add("ktlint", "com.pinterest.ktlint:ktlint-cli:1.5.0") {
242+
add("ktlint", "com.pinterest.ktlint:ktlint-cli:1.8.0") {
243243
attributes {
244244
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
245245
}

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Action.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ abstract class Action(
6161
// start a new action
6262
stateMetaData?.name != stateName ->
6363
ActionMetaData(this.type, Instant.now().toEpochMilli(), this.actionIndex, false, 0, 0, null)
64+
6465
actionMetaData?.index != this.actionIndex ->
6566
ActionMetaData(this.type, Instant.now().toEpochMilli(), this.actionIndex, false, 0, 0, null)
67+
6668
// RetryAPI will reset startTime to null for actionMetaData and we'll reset it to "now" here
6769
else -> actionMetaData.copy(startTime = actionMetaData.startTime ?: Instant.now().toEpochMilli())
6870
}

spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/Step.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,14 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) {
137137

138138
final fun getStepStartTime(metadata: ManagedIndexMetaData): Instant = when {
139139
metadata.stepMetaData == null -> Instant.now()
140+
140141
metadata.stepMetaData.name != this.name -> Instant.now()
142+
141143
// The managed index metadata is a historical snapshot of the metadata and refers to what has happened from the previous
142144
// execution, so if we ever see it as COMPLETED it means we are always going to be in a new step, this specifically
143145
// helps with the Transition -> Transition (empty state) sequence which the above do not capture
144146
metadata.stepMetaData.stepStatus == StepStatus.COMPLETED -> Instant.now()
147+
145148
else -> Instant.ofEpochMilli(metadata.stepMetaData.startTime)
146149
}
147150

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,17 @@ data class ActionMetaData(
120120

121121
when (fieldName) {
122122
NAME -> name = xcp.text()
123+
123124
START_TIME -> startTime = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else xcp.longValue()
125+
124126
INDEX -> index = xcp.intValue()
127+
125128
FAILED -> failed = xcp.booleanValue()
129+
126130
CONSUMED_RETRIES -> consumedRetries = xcp.intValue()
131+
127132
LAST_RETRY_TIME -> lastRetryTime = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else xcp.longValue()
133+
128134
ActionProperties.ACTION_PROPERTIES ->
129135
actionProperties = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else ActionProperties.parse(xcp)
130136
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,17 @@ data class ActionProperties(
7575

7676
when (fieldName) {
7777
Properties.MAX_NUM_SEGMENTS.key -> maxNumSegments = xcp.intValue()
78+
7879
Properties.SNAPSHOT_NAME.key -> snapshotName = xcp.text()
80+
7981
Properties.ROLLUP_ID.key -> rollupId = xcp.text()
82+
8083
Properties.HAS_ROLLUP_FAILED.key -> hasRollupFailed = xcp.booleanValue()
84+
8185
ShrinkActionProperties.SHRINK_ACTION_PROPERTIES -> {
8286
shrinkActionProperties = if (xcp.currentToken() == Token.VALUE_NULL) null else ShrinkActionProperties.parse(xcp)
8387
}
88+
8489
TransformActionProperties.TRANSFORM_ACTION_PROPERTIES -> {
8590
transformActionProperties = if (xcp.currentToken() == Token.VALUE_NULL) null else TransformActionProperties.parse(xcp)
8691
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,27 +259,41 @@ data class ManagedIndexMetaData(
259259

260260
when (fieldName) {
261261
INDEX -> index = xcp.text()
262+
262263
INDEX_UUID -> indexUuid = xcp.text()
264+
263265
POLICY_ID -> policyID = xcp.text()
266+
264267
POLICY_SEQ_NO -> policySeqNo = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else xcp.longValue()
268+
265269
POLICY_PRIMARY_TERM -> policyPrimaryTerm = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else xcp.longValue()
270+
266271
POLICY_COMPLETED -> policyCompleted = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else xcp.booleanValue()
272+
267273
ROLLED_OVER -> rolledOver = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else xcp.booleanValue()
274+
268275
ROLLED_OVER_INDEX_NAME -> rolledOverIndexName = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else xcp.text()
276+
269277
INDEX_CREATION_DATE -> indexCreationDate = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else xcp.longValue()
278+
270279
TRANSITION_TO -> transitionTo = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else xcp.text()
280+
271281
StateMetaData.STATE -> {
272282
state = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else StateMetaData.parse(xcp)
273283
}
284+
274285
ActionMetaData.ACTION -> {
275286
action = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else ActionMetaData.parse(xcp)
276287
}
288+
277289
StepMetaData.STEP -> {
278290
step = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) null else StepMetaData.parse(xcp)
279291
}
292+
280293
PolicyRetryInfoMetaData.RETRY_INFO -> {
281294
retryInfo = PolicyRetryInfoMetaData.parse(xcp)
282295
}
296+
283297
INFO -> info = xcp.map()
284298
// below line will break when getting metadata for explain or history
285299
// else -> throw IllegalArgumentException("Invalid field: [$fieldName] found in ManagedIndexMetaData.")

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,30 +269,39 @@ class IndexManagementPlugin :
269269
ManagedIndexConfig.MANAGED_INDEX_TYPE -> {
270270
return@ScheduledJobParser ManagedIndexConfig.parse(xcp, id, jobDocVersion.seqNo, jobDocVersion.primaryTerm)
271271
}
272+
272273
Policy.POLICY_TYPE -> {
273274
return@ScheduledJobParser null
274275
}
276+
275277
Rollup.ROLLUP_TYPE -> {
276278
return@ScheduledJobParser Rollup.parse(xcp, id, jobDocVersion.seqNo, jobDocVersion.primaryTerm)
277279
}
280+
278281
RollupMetadata.ROLLUP_METADATA_TYPE -> {
279282
return@ScheduledJobParser null
280283
}
284+
281285
Transform.TRANSFORM_TYPE -> {
282286
return@ScheduledJobParser Transform.parse(xcp, id, jobDocVersion.seqNo, jobDocVersion.primaryTerm)
283287
}
288+
284289
TransformMetadata.TRANSFORM_METADATA_TYPE -> {
285290
return@ScheduledJobParser null
286291
}
292+
287293
ManagedIndexMetaData.MANAGED_INDEX_METADATA_TYPE -> {
288294
return@ScheduledJobParser null
289295
}
296+
290297
SMPolicy.SM_TYPE -> {
291298
return@ScheduledJobParser SMPolicy.parse(xcp, id, jobDocVersion.seqNo, jobDocVersion.primaryTerm)
292299
}
300+
293301
SMMetadata.SM_METADATA_TYPE -> {
294302
return@ScheduledJobParser null
295303
}
304+
296305
else -> {
297306
logger.warn("Unsupported document was indexed in $INDEX_MANAGEMENT_INDEX with type: $fieldName")
298307
xcp.skipChildren()

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ object IndexManagementRunner : ScheduledJobRunner {
2424
override fun runJob(job: ScheduledJobParameter, context: JobExecutionContext) {
2525
when (job) {
2626
is ManagedIndexConfig -> ManagedIndexRunner.runJob(job, context)
27+
2728
is Rollup -> RollupRunner.runJob(job, context)
29+
2830
is Transform -> TransformRunner.runJob(job, context)
31+
2932
is SMPolicy -> SMRunner.runJob(job, context)
33+
3034
else -> {
3135
val errorMessage = "Invalid job type, found ${job.javaClass.simpleName} with id: ${context.jobId}"
3236
logger.error(errorMessage)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ data class Channel(val id: String) :
5959
xcp.nextToken()
6060
when (fieldName) {
6161
ID -> id = xcp.text()
62+
6263
else -> {
6364
error("Unexpected field: $fieldName, while parsing Channel destination")
6465
}

src/main/kotlin/org/opensearch/indexmanagement/controlcenter/notification/filter/NotificationActionListener.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,13 @@ class NotificationActionListener<Request : ActionRequest, Response : ActionRespo
288288
if (runtimeConfig != null) channels.add(runtimeConfig)
289289
if (defaultConfig != null) channels.add(defaultConfig)
290290

291-
return channels.filter { ch ->
292-
val condition = ch.lronConfig.lronCondition
293-
condition.success && result == OperationResult.COMPLETE || condition.failure && result != OperationResult.COMPLETE
294-
}.toSet()
291+
return channels
292+
.filter { ch ->
293+
val condition = ch.lronConfig.lronCondition
294+
(condition.success && result == OperationResult.COMPLETE) ||
295+
(condition.failure && result != OperationResult.COMPLETE)
296+
}
297+
.toSet()
295298
}
296299

297300
fun escapeQueryString(query: String): String = query.replace("/", "\\/").replace(":", "\\:")

0 commit comments

Comments
 (0)