Skip to content

Commit

Permalink
Reduce code difference
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn committed Jan 25, 2023
1 parent 76d530f commit f08bfd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ buildscript {
if (isSnapshot) {
opensearch_build += "-SNAPSHOT"
}
if (!isSnapshot) {
opensearch_version = opensearch_version.replace("-SNAPSHOT","")
}
opensearch_no_snapshot = opensearch_version.replace("-SNAPSHOT","")
job_scheduler_resource_folder = "src/test/resources/job-scheduler"

Expand Down Expand Up @@ -637,12 +640,10 @@ String bwc_im_resource_location = bwcFilePath + "indexmanagement/" + bwcVersion
// Downloads the bwc job scheduler version
String bwc_js_download_url = "https://github.com/opendistro-for-elasticsearch/job-scheduler/releases/download/v" +
bwcJobSchedulerVersion + "/job-scheduler-artifacts.zip"
getPluginResource(bwc_js_resource_location, bwc_js_download_url)

// Downloads the bwc index management version
String bwc_im_download_url = "https://github.com/opendistro-for-elasticsearch/index-management/releases/download/v" +
bwcVersion + "/index-management-artifacts.zip"
getPluginResource(bwc_im_resource_location, bwc_im_download_url)

2.times {i ->
testClusters {
Expand Down Expand Up @@ -686,6 +687,8 @@ List<Provider<RegularFile>> plugins = []
task prepareBwcTests {
dependsOn bundlePlugin
doLast {
getPluginResource(bwc_js_resource_location, bwc_js_download_url)
getPluginResource(bwc_im_resource_location, bwc_im_download_url)
// Download the job scheduler test dependency
getPluginResource(job_scheduler_resource_folder, job_scheduler_build_download)
plugins = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import org.opensearch.indexmanagement.indexstatemanagement.settings.ManagedIndex
import org.opensearch.indexmanagement.indexstatemanagement.settings.ManagedIndexSettings.Companion.TEMPLATE_MIGRATION_CONTROL
import org.opensearch.indexmanagement.indexstatemanagement.transport.action.managedIndex.ManagedIndexAction
import org.opensearch.indexmanagement.indexstatemanagement.transport.action.managedIndex.ManagedIndexRequest
import org.opensearch.indexmanagement.indexstatemanagement.util.DEFAULT_INDEX_TYPE
import org.opensearch.indexmanagement.indexstatemanagement.util.ISM_TEMPLATE_FIELD
import org.opensearch.indexmanagement.indexstatemanagement.util.deleteManagedIndexMetadataRequest
import org.opensearch.indexmanagement.indexstatemanagement.util.deleteManagedIndexRequest
Expand Down Expand Up @@ -328,10 +329,15 @@ class ManagedIndexCoordinator(
val ismIndicesMetadata: Map<String, ISMIndexMetadata> = indexMetadataProvider.getISMIndexMetadataByType(indexNames = indexNames)
// Iterate over each unmanaged hot/warm index and if it matches an ISM template add a managed index config index request
indexNames.forEach { indexName ->
val defaultIndexMetadataService = indexMetadataProvider.services[DEFAULT_INDEX_TYPE] as DefaultIndexMetadataService
// If there is a custom index uuid associated with the index, we do not auto manage it
// This is because cold index uses custom uuid, and we do not auto manage cold-to-warm index
val indexMetadata = clusterState.metadata.index(indexName)
val wasOffCluster = defaultIndexMetadataService.getCustomIndexUUID(indexMetadata) != indexMetadata.indexUUID
val ismIndexMetadata = ismIndicesMetadata[indexName]
// We try to find lookup name instead of using index name as datastream indices need the alias to match policy
val lookupName = findIndexLookupName(indexName, clusterState)
if (lookupName != null && !indexMetadataProvider.isUnManageableIndex(lookupName) && ismIndexMetadata != null) {
if (lookupName != null && !indexMetadataProvider.isUnManageableIndex(lookupName) && ismIndexMetadata != null && !wasOffCluster) {
val creationDate = ismIndexMetadata.indexCreationDate
val indexUuid = ismIndexMetadata.indexUuid
findMatchingPolicy(lookupName, creationDate, policiesWithTemplates)
Expand Down

0 comments on commit f08bfd2

Please sign in to comment.