Skip to content

Commit

Permalink
Fix the JVM we use for bwc nodes (#46314)
Browse files Browse the repository at this point in the history
Before this change we would run bwc nodes with their bundled jdk if
these supported it, so the passed in runtime JDK was not honored.
This became obvius when running with FIPS.

Closes #41721
  • Loading branch information
alpar-t committed Sep 9, 2019
1 parent 948ea49 commit 2bfd12e
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,7 @@ class ClusterFormationTasks {
static Task configureExecTask(String name, Project project, Task setup, NodeInfo node, Object[] execArgs) {
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) { Exec exec ->
exec.workingDir node.cwd
if ((project.isRuntimeJavaHomeSet && node.isBwcNode == false) // runtime Java might not be compatible with old nodes
|| node.nodeVersion.before(Version.fromString("7.0.0"))
|| node.config.distribution == 'integ-test-zip') {
if (useRuntimeJava(project, node)) {
exec.environment.put('JAVA_HOME', project.runtimeJavaHome)
} else {
// force JAVA_HOME to *not* be set
Expand All @@ -707,16 +705,20 @@ class ClusterFormationTasks {
}
}

public static boolean useRuntimeJava(Project project, NodeInfo node) {
return (project.isRuntimeJavaHomeSet ||
(node.isBwcNode == false && node.nodeVersion.before(Version.fromString("7.0.0"))) ||
node.config.distribution == 'integ-test-zip')
}

/** Adds a task to start an elasticsearch node with the given configuration */
static Task configureStartTask(String name, Project project, Task setup, NodeInfo node) {
// this closure is converted into ant nodes by groovy's AntBuilder
Closure antRunner = { AntBuilder ant ->
ant.exec(executable: node.executable, spawn: node.config.daemonize, newenvironment: true,
dir: node.cwd, taskname: 'elasticsearch') {
node.env.each { key, value -> env(key: key, value: value) }
if ((project.isRuntimeJavaHomeSet && node.isBwcNode == false) // runtime Java might not be compatible with old nodes
|| node.nodeVersion.before(Version.fromString("7.0.0"))
|| node.config.distribution == 'integ-test-zip') {
if (useRuntimeJava(project, node)) {
env(key: 'JAVA_HOME', value: project.runtimeJavaHome)
}
node.args.each { arg(value: it) }
Expand Down

0 comments on commit 2bfd12e

Please sign in to comment.