diff --git a/build.gradle b/build.gradle index aba7c3d1b..c761a15fb 100644 --- a/build.gradle +++ b/build.gradle @@ -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" @@ -80,7 +83,7 @@ buildscript { plugins { id 'nebula.ospackage' version "8.3.0" - id "com.dorongold.task-tree" version "1.5" + id "com.dorongold.task-tree" version "2.1.1" } apply plugin: 'java' @@ -324,10 +327,16 @@ test { } ext.getPluginResource = { download_to_folder, download_from_src -> - project.mkdir download_to_folder - ant.get(src: download_from_src, - dest: download_to_folder, - httpusecaches: false) + def src_split = download_from_src.split("/") + def download_file = src_split[src_split.length-1] + if (!fileTree(download_to_folder).contains(new File("$project.rootDir/$download_to_folder/$download_file"))) { + println("Downloading ${download_file}") + project.delete download_to_folder + project.mkdir download_to_folder + ant.get(src: download_from_src, + dest: download_to_folder, + httpusecaches: false) + } return fileTree(download_to_folder).getSingleFile() } @@ -637,12 +646,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 { @@ -656,7 +663,7 @@ getPluginResource(bwc_im_resource_location, bwc_im_download_url) return new RegularFile() { @Override File getAsFile() { - return fileTree(bwc_js_resource_location).getSingleFile() + return getPluginResource(bwc_js_resource_location, bwc_js_download_url) } } } @@ -668,7 +675,7 @@ getPluginResource(bwc_im_resource_location, bwc_im_download_url) return new RegularFile() { @Override File getAsFile() { - return fileTree(bwc_im_resource_location).getSingleFile() + return getPluginResource(bwc_im_resource_location, bwc_im_download_url) } } } @@ -686,6 +693,8 @@ List> 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 = [ @@ -725,8 +734,8 @@ task prepareBwcTests { // This results in a mixed cluster with 2 nodes on the old version and 1 upgraded node. // This is also used as a one third upgraded cluster for a rolling upgrade. task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) { - useCluster testClusters."${baseName}0" dependsOn "${baseName}#oldVersionClusterTask0" + useCluster testClusters."${baseName}0" doFirst { testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins) } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt index 20b621f99..bb286ea9e 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt @@ -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 @@ -315,7 +316,7 @@ class ManagedIndexCoordinator( /** * build requests to create jobs for indices matching ISM templates */ - @Suppress("NestedBlockDepth") + @Suppress("NestedBlockDepth", "ComplexCondition") private suspend fun createManagedIndexRequests( clusterState: ClusterState, indexNames: List @@ -328,10 +329,15 @@ class ManagedIndexCoordinator( val ismIndicesMetadata: Map = 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)