Skip to content

Commit

Permalink
Gradle to 7.6.1 and Gradle test-retry to 1.5.2, Also moving the docke…
Browse files Browse the repository at this point in the history
…rBuild to use Maven repo for PA Artifact instead of git clone plugin (#358)

Signed-off-by: Khushboo Rajput <khushbr@amazon.com>
  • Loading branch information
khushbr authored May 12, 2023
1 parent d774901 commit 3408269
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 164 deletions.
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ You can use the packaged Dockerfile and docker-compose.yml files [here](./docker
1. Make sure you're in the `rca-infra` folder.

2. Build and tag the Docker image with our RCA framework.

`docker build -t opensearch/pa-rca:2.7 .`

3. Spin up a two node cluster as follows:

`DATA_VOLUME1=opensearchdata1 DATA_VOLUME2=opensearchdata2 docker-compose -f docker-compose.yml -f docker-compose.hostports.yml -f docker-compose.cluster.yml up opensearch1 opensearch2`
Expand Down
74 changes: 24 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ buildscript {

dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
classpath group: 'com.google.guava', name: 'guava', version: '30.1-jre'
classpath 'org.ajoberstar:gradle-git:0.2.3'
classpath group: 'com.google.guava', name: 'guava', version: '31.1-jre'
}
}

Expand All @@ -49,7 +48,7 @@ plugins {
id 'com.github.spotbugs' version '5.0.13'
id "de.undercouch.download" version "4.0.4"
id 'com.adarshr.test-logger' version '2.1.0'
id 'org.gradle.test-retry' version '1.3.1'
id 'org.gradle.test-retry' version '1.5.2'
id 'com.diffplug.spotless' version '5.11.0'
}

Expand Down Expand Up @@ -255,6 +254,8 @@ tasks.withType(Test) {
jvmArgs('--add-opens=java.base/java.util.stream=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/sun.nio.fs=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.nio.file=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.lang=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.util=ALL-UNNAMED')
}

task rcaTest(type: Test) {
Expand Down Expand Up @@ -307,10 +308,12 @@ project.afterEvaluate {

repositories {
mavenCentral()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}

configurations {
includeJars
dockerBuild
}

tasks.withType(JavaCompile) {
Expand Down Expand Up @@ -373,6 +376,9 @@ dependencies {
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.1'
testImplementation group: 'junit', name: 'junit', version: "${junitVersion}"

// Required for Docker build
dockerBuild group: 'org.opensearch.plugin', name:'performance-analyzer', version: "${opensearch_build}"
}

configurations.each {
Expand Down Expand Up @@ -412,83 +418,51 @@ idea {

import groovy.json.JsonSlurper
import java.nio.file.Paths
import org.ajoberstar.gradle.git.tasks.GitClone

String paDir
String dockerBuildDir
String dockerArtifactsDir
String file_ext = "zip"

task clonePaGitRepo(type: GitClone) {
task pullPAPlugin(type: Copy) {
dockerBuildDir = Paths.get(getProject().getBuildDir().toString(), "docker-build").toString()
mkdir dockerBuildDir
if (localPaDir != null && !localPaDir.empty) {
// If you already have the performance Analyzer sources checked out then update the
// localPaDir in gradle.properties with the path.
paDir = localPaDir
} else {
paDir = Paths.get(dockerBuildDir, "pa").toString()
}

def destination = file(paDir)
uri = gitPaRepo
branch = gitPaBranch
destinationPath = destination
bare = false
enabled = !destination.exists() //to clone only once
}
paDir = Paths.get(dockerBuildDir, "pa")
mkdir paDir

task removeLicenses(type: Delete) {
dependsOn(clonePaGitRepo)
def toDelete = Paths.get(paDir, 'licenses', "performanceanalyzer-rca-${version}.jar.sha1")
delete(toDelete)
}

task regenerateLicenses(type: Exec) {
dependsOn(removeLicenses)
workingDir(paDir)
commandLine './gradlew', 'updateShas'
}

task buildPa(type: Exec) {
dependsOn(assemble, publishToMavenLocal, regenerateLicenses)
workingDir paDir
println String.format('pa in dir: (%s) will be built.', paDir)
println String.format('opensearch_version: (%s), plugin_version: (%s), snapshot: (%s), qualifier: (%s).', opensearch_version, version, isSnapshot, buildVersionQualifier)
if (buildVersionQualifier == null || buildVersionQualifier == '' || buildVersionQualifier == 'null') {
commandLine './gradlew', 'assemble', "-Dopensearch.version=${opensearch_version}", "-Dbuild.snapshot=${isSnapshot}"
}
else {
commandLine './gradlew', 'assemble', "-Dopensearch.version=${opensearch_version}", "-Dbuild.snapshot=${isSnapshot}", "-Dbuild.version_qualifier=${buildVersionQualifier}"
}
println "PA repo located at '" + paDir + "' will be used."
from(configurations.dockerBuild)
into(paDir)
println String.format('Pulled PA Plugin at: (%s), will be used for Docker Build', Paths.get(paDir, "performance-analyzer-${version}.${file_ext}"))
}

task copyAllArtifacts(type: Copy) {
dependsOn(buildPa)
dependsOn(assemble, publishToMavenLocal, pullPAPlugin)
def projectPathStr = getProjectDir().toPath().toString()
def dockerArtifacts = Paths.get(projectPathStr, 'docker').toString()
def rcaArtifacts = Paths.get(projectPathStr, 'build', 'distributions', "performance-analyzer-rca-${version}.zip")
def paArtifacts = Paths.get(paDir, 'build', 'distributions', "opensearch-performance-analyzer-${version}.zip")
def rcaArtifacts = Paths.get(projectPathStr, 'build', 'distributions', "performance-analyzer-rca-${version}.${file_ext}")
def paArtifacts = Paths.get(dockerBuildDir, 'pa', "performance-analyzer-${version}.${file_ext}")

dockerArtifactsDir = Paths.get(dockerBuildDir, 'rca-docker')
mkdir dockerArtifactsDir

from(dockerArtifacts)
from(rcaArtifacts)
from(paArtifacts)
into(dockerArtifactsDir)
}

task copyReaderMetricsFiles(type: Copy) {
dependsOn(buildPa)
copy{
from ('src/test/resources/reader'){
dependsOn(pullPAPlugin)
copy {
from ('src/test/resources/reader') {
}
into 'build/private/test_resources'
}
}

task buildDocker(type: Exec) {
dependsOn(copyAllArtifacts)

workingDir(dockerArtifactsDir)
commandLine 'docker', 'build', '-t', 'opensearch/pa-rca:2.7', '.', '--build-arg', "JDK_VER=${buildDockerJdkVersion}"
}
Expand Down
7 changes: 3 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ COPY --chown=1000:0 opensearch.yml log4j2.properties config/

COPY --chown=1000:0 performance-analyzer-rca-2.7.0.0-SNAPSHOT.zip config/

COPY --chown=1000:0 opensearch-performance-analyzer-2.7.0.0-SNAPSHOT.zip /tmp/

RUN opensearch-plugin install --batch file:///tmp/opensearch-performance-analyzer-2.7.0.0-SNAPSHOT.zip; \
rm /tmp/opensearch-performance-analyzer-2.7.0.0-SNAPSHOT.zip
COPY --chown=1000:0 performance-analyzer-2.7.0.0-SNAPSHOT.zip /tmp/

RUN opensearch-plugin install --batch file:///tmp/performance-analyzer-2.7.0.0-SNAPSHOT.zip; \
rm /tmp/performance-analyzer-2.7.0.0-SNAPSHOT.zip
USER 0

# Set gid to 0 for opensearch and make group permission similar to that of user
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
# SPDX-License-Identifier: Apache-2.0
#

localPaDir=../performance-analyzer
# Below were added to fix build issue. Refer - https://github.com/diffplug/spotless/issues/834
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jan 28 11:59:31 PST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 3408269

Please sign in to comment.