diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt b/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt index 176b6d1d4..d8e360155 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt @@ -474,7 +474,7 @@ class AlertIndices( clusterStateRequest, object : ActionListener { override fun onResponse(clusterStateResponse: ClusterStateResponse) { - if (!clusterStateResponse.state.metadata.indices.isEmpty) { + if (!clusterStateResponse.state.metadata.indices.isEmpty()) { val indicesToDelete = getIndicesToDelete(clusterStateResponse) logger.info("Deleting old $tag indices viz $indicesToDelete") deleteAllOldHistoryIndices(indicesToDelete) @@ -509,7 +509,7 @@ class AlertIndices( ): String? { val creationTime = indexMetadata.creationDate if ((Instant.now().toEpochMilli() - creationTime) > retentionPeriodMillis) { - val alias = indexMetadata.aliases.firstOrNull { writeIndex == it.value.alias } + val alias = indexMetadata.aliases.entries.firstOrNull { writeIndex == it.value.alias } if (alias != null) { if (historyEnabled) { // If the index has the write alias and history is enabled, don't delete the index diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/util/IndexUtils.kt b/alerting/src/main/kotlin/org/opensearch/alerting/util/IndexUtils.kt index 07de1b976..27b6fa9fa 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/util/IndexUtils.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/util/IndexUtils.kt @@ -99,7 +99,7 @@ class IndexUtils { @JvmStatic fun getIndexNameWithAlias(clusterState: ClusterState, alias: String): String { - return clusterState.metadata.indices.first { it.value.aliases.containsKey(alias) }.key + return clusterState.metadata.indices.entries.first { it.value.aliases.containsKey(alias) }.key } @JvmStatic @@ -126,7 +126,7 @@ class IndexUtils { actionListener: ActionListener ) { if (clusterState.metadata.indices.containsKey(index)) { - if (shouldUpdateIndex(clusterState.metadata.indices[index], mapping)) { + if (shouldUpdateIndex(clusterState.metadata.indices[index]!!, mapping)) { val putMappingRequest: PutMappingRequest = PutMappingRequest(index).source(mapping, XContentType.JSON) client.putMapping(putMappingRequest, actionListener) } else { diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/transport/AlertingSingleNodeTestCase.kt b/alerting/src/test/kotlin/org/opensearch/alerting/transport/AlertingSingleNodeTestCase.kt index ea1022f1d..8c889a426 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/transport/AlertingSingleNodeTestCase.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/transport/AlertingSingleNodeTestCase.kt @@ -111,9 +111,9 @@ abstract class AlertingSingleNodeTestCase : OpenSearchSingleNodeTestCase() { protected fun assertAliasNotExists(alias: String) { val aliasesResponse = client().admin().indices().getAliases(GetAliasesRequest()).get() - val foundAlias = aliasesResponse.aliases.values().forEach { - it.value.forEach { - if (it.alias == alias) { + val foundAlias = aliasesResponse.aliases.values.forEach { + it.forEach { it1 -> + if (it1.alias == alias) { fail("alias exists, but it shouldn't") } } @@ -122,9 +122,9 @@ abstract class AlertingSingleNodeTestCase : OpenSearchSingleNodeTestCase() { protected fun assertAliasExists(alias: String) { val aliasesResponse = client().admin().indices().getAliases(GetAliasesRequest()).get() - val foundAlias = aliasesResponse.aliases.values().forEach { - it.value.forEach { - if (it.alias == alias) { + val foundAlias = aliasesResponse.aliases.values.forEach { + it.forEach { it1 -> + if (it1.alias == alias) { return } } diff --git a/build-tools/merged-coverage.gradle b/build-tools/merged-coverage.gradle index c4e07ab75..83fa44d20 100644 --- a/build-tools/merged-coverage.gradle +++ b/build-tools/merged-coverage.gradle @@ -13,26 +13,18 @@ allprojects { } } -task jacocoMerge(type: JacocoMerge) { +task jacocoReport(type: JacocoReport, group: 'verification') { + description = 'Generates an aggregate report from all subprojects' gradle.projectsEvaluated { - subprojects.each { - jacocoMerge.dependsOn it.tasks.withType(JacocoReport) - jacocoMerge.executionData it.tasks.withType(JacocoReport).collect { it.executionData } + subprojects.each { + jacocoReport.dependsOn it.tasks.withType(JacocoReport) + jacocoReport.executionData it.tasks.withType(JacocoReport).collect { it.executionData } } } - doFirst { - executionData = files(executionData.findAll { it.exists() }) - } -} - -task jacocoReport(type: JacocoReport, group: 'verification') { - description = 'Generates an aggregate report from all subprojects' - dependsOn jacocoMerge - executionData jacocoMerge.destinationFile reports { - html.enabled = true // human readable - xml.enabled = true + html.required = true // human readable + xml.required = true } gradle.projectsEvaluated { diff --git a/build-tools/opensearchplugin-coverage.gradle b/build-tools/opensearchplugin-coverage.gradle index adea8414e..df2c0513b 100644 --- a/build-tools/opensearchplugin-coverage.gradle +++ b/build-tools/opensearchplugin-coverage.gradle @@ -61,8 +61,8 @@ jacocoTestReport { getSourceDirectories().from(sourceSets.main.allSource) getClassDirectories().from(sourceSets.main.output) reports { - html.enabled = true // human readable - xml.enabled = true // for coverlay + html.required = true // human readable + xml.required = true // for coverlay } } diff --git a/build-tools/pkgbuild.gradle b/build-tools/pkgbuild.gradle index 4ac3eb325..8a70c13e3 100644 --- a/build-tools/pkgbuild.gradle +++ b/build-tools/pkgbuild.gradle @@ -1,4 +1,4 @@ -apply plugin: 'nebula.ospackage' +apply plugin: 'com.netflix.nebula.ospackage' // This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name afterEvaluate { @@ -8,7 +8,7 @@ afterEvaluate { version = "${project.version}" - "-SNAPSHOT" into '/usr/share/opensearch/plugins' - from(zipTree(bundlePlugin.archivePath)) { + from(zipTree(bundlePlugin.archiveFile)) { into opensearchplugin.name } @@ -39,9 +39,8 @@ afterEvaluate { task renameRpm(type: Copy) { from("$buildDir/distributions") into("$buildDir/distributions") - include archiveName - rename archiveName, "${packageName}-${version}.rpm" - doLast { delete file("$buildDir/distributions/$archiveName") } + rename "$archiveFileName", "${packageName}-${archiveVersion}.rpm" + doLast { delete file("$buildDir/distributions/$archiveFileName") } } } @@ -52,9 +51,8 @@ afterEvaluate { task renameDeb(type: Copy) { from("$buildDir/distributions") into("$buildDir/distributions") - include archiveName - rename archiveName, "${packageName}-${version}.deb" - doLast { delete file("$buildDir/distributions/$archiveName") } + rename "$archiveFileName", "${packageName}-${archiveVersion}.deb" + doLast { delete file("$buildDir/distributions/$archiveFileName") } } } } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 72d5f7910..bec3b5f58 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ buildscript { } plugins { - id 'nebula.ospackage' version "8.3.0" apply false + id 'com.netflix.nebula.ospackage' version "11.0.0" id "com.dorongold.task-tree" version "1.5" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832f..c1962a79e 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661ee..37aef8d3f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb6c..aeb74cbb4 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -143,12 +140,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/gradlew.bat b/gradlew.bat index 53a6b238d..6689b85be 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME%