Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias index transform #1049

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e5631ac
adding write index check for alias of target index
n-dohrmann Nov 21, 2023
7fbde10
trying out putMapping changes
n-dohrmann Nov 29, 2023
e0274ec
linting previous change
n-dohrmann Nov 29, 2023
f866378
variable target index PR ready for discussion...
n-dohrmann Nov 29, 2023
4abb60f
Merge branch 'main' into alias_index_transform
n-dohrmann Nov 29, 2023
e687f5f
linting previous commit
n-dohrmann Nov 29, 2023
f70faab
Merge branch 'alias_index_transform' of github.com:n-dohrmann/index-m…
n-dohrmann Nov 29, 2023
a3586f5
reduce throw count to < 2 in createTargetIndex
n-dohrmann Nov 29, 2023
024696c
adding write index check for alias of target index
n-dohrmann Nov 21, 2023
3e43d36
trying out putMapping changes
n-dohrmann Nov 29, 2023
123378b
linting previous change
n-dohrmann Nov 29, 2023
ef70a74
variable target index PR ready for discussion...
n-dohrmann Nov 29, 2023
3be1246
linting previous commit
n-dohrmann Nov 29, 2023
4138ff0
reduce throw count to < 2 in createTargetIndex
n-dohrmann Nov 29, 2023
7db746d
Merge branch 'alias_index_transform' of github.com:n-dohrmann/index-m…
n-dohrmann Nov 30, 2023
01bd3a2
changing alias checker control flow
n-dohrmann Dec 5, 2023
ab17632
adding test case for aliased transform target index
n-dohrmann Dec 6, 2023
448161b
quick commit before changing branches
n-dohrmann Dec 14, 2023
0b02a23
Merge branch 'main' into alias_index_transform
n-dohrmann Dec 14, 2023
e50468b
adding code for quick question
n-dohrmann Dec 15, 2023
7dd3530
adding to target alias transform test
n-dohrmann Dec 15, 2023
ce65e6c
Merge branch 'main' into alias_index_transform
n-dohrmann Dec 15, 2023
a738944
adding explicit variable for sourceIndex
n-dohrmann Dec 15, 2023
0bb9ce8
adding unchecked cast suppressor to test method
n-dohrmann Dec 15, 2023
7cf342a
Merge branch 'main' into alias_index_transform
bowenlan-amzn Jan 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.opensearch.action.DocWriteRequest
import org.opensearch.action.admin.indices.create.CreateIndexRequest
import org.opensearch.action.admin.indices.create.CreateIndexResponse
import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest
import org.opensearch.action.bulk.BackoffPolicy
import org.opensearch.action.bulk.BulkItemResponse
import org.opensearch.action.bulk.BulkRequest
Expand All @@ -26,6 +27,7 @@
import org.opensearch.indexmanagement.transform.util.TransformContext
import org.opensearch.core.rest.RestStatus
import org.opensearch.transport.RemoteTransportException
import org.opensearch.action.support.master.AcknowledgedResponse

@Suppress("ComplexMethod")
class TransformIndexer(
Expand Down Expand Up @@ -63,6 +65,20 @@
throw TransformIndexException("Failed to create the target index")
}
}
val writeIndexMetadata = clusterService.state().metadata.indicesLookup[targetIndex]!!.writeIndex

Check warning on line 68 in src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt#L68

Added line #L68 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should inside the below if block?

if (clusterService.state().metadata.hasAlias(targetIndex)) {
// return error if no write index with the alias
if (writeIndexMetadata == null) {
throw TransformIndexException("Target index alias has no write index")

Check warning on line 72 in src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt#L72

Added line #L72 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_index [$targetIndex] is an alias but doesn't have write index

}
}
val putMappingReq = PutMappingRequest(writeIndexMetadata?.index?.name).source(targetFieldMappings)
val mapResp: AcknowledgedResponse = client.admin().indices().suspendUntil {
putMapping(putMappingReq)

Check warning on line 77 in src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt#L76-L77

Added lines #L76 - L77 were not covered by tests
}
if (!mapResp.isAcknowledged) {
logger.error("Target index mapping request failed")

Check warning on line 80 in src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/indexmanagement/transform/TransformIndexer.kt#L80

Added line #L80 was not covered by tests
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also move this inside to above if block?

}

@Suppress("ThrowsCount", "RethrowCaughtException")
Expand Down
Loading