Skip to content

Commit

Permalink
Remove version from JDK path (#1516)
Browse files Browse the repository at this point in the history
Remove version from JDK path when JDKs are included in dists.
  • Loading branch information
CRogers authored Sep 1, 2023
1 parent 5bd63ee commit d289acd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1516.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Remove version from JDK path when JDKs are included in dists.
links:
- https://github.com/palantir/sls-packaging/pull/1516
Original file line number Diff line number Diff line change
Expand Up @@ -265,19 +265,18 @@ private static GcProfile getDefaultGcProfile(JavaVersion javaVersion) {
return new GcProfile.Throughput();
}

final String jdkPathInDist(JavaVersion javaVersionValue) {
public final String jdkPathInDist(JavaVersion javaVersionValue) {
// We put the JDK in a directory that contains the name and version of service. This is because in our cloud
// environments (and some customer environments), there is a third party security scanning tool that will report
// vulnerabilities in the JDK by printing a path, but does not display symlinks. This means it's hard to tell
// from a scan report which service is actually vulnerable, as our internal deployment infra uses symlinks,
// and you end up with a report like so:
// Path: /opt/palantir/services/.24710105/service/jdk17
// rather than more useful:
// Path: /opt/palantir/services/.24710105/service/multipass-2.1.3-jdks/jdk17
// Path: /opt/palantir/services/.24710105/service/multipass-jdks/jdk17
// which is implemented below.

return String.format(
"service/%s-%s-jdks/jdk%s",
getDistributionServiceName().get(), project.getVersion(), javaVersionValue.getMajorVersion());
"service/%s-jdks/jdk%s", getDistributionServiceName().get(), javaVersionValue.getMajorVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ class JdksInDistsIntegrationSpec extends IntegrationSpec {

then:
def rootDir = extractDist()
def jdkDir = new File(rootDir, "service/myService-1.0.0-jdks/jdk17")
def jdkDir = new File(rootDir, "service/myService-jdks/jdk17")
jdkDir.exists()

def releaseFileText = new File(jdkDir, "release").text

releaseFileText.contains 'its a jdk trust me'

def launcherStatic = new File(rootDir, "service/bin/launcher-static.yml").text
launcherStatic.contains 'javaHome: "service/myService-1.0.0-jdks/jdk17"'
launcherStatic.contains ' JAVA_17_HOME: "service/myService-1.0.0-jdks/jdk17"'
launcherStatic.contains 'javaHome: "service/myService-jdks/jdk17"'
launcherStatic.contains ' JAVA_17_HOME: "service/myService-jdks/jdk17"'
}

def 'multiple jdks can exist in the dist'() {
Expand All @@ -103,17 +103,17 @@ class JdksInDistsIntegrationSpec extends IntegrationSpec {
def rootDir = extractDist()

def launcherStatic = new File(rootDir, "service/bin/launcher-static.yml").text
launcherStatic.contains 'javaHome: "service/myService-1.0.0-jdks/jdk17"'
launcherStatic.contains 'javaHome: "service/myService-jdks/jdk17"'

for (version in [11, 13, 17]) {
def jdkDir = new File(rootDir, "service/myService-1.0.0-jdks/jdk" + version)
def jdkDir = new File(rootDir, "service/myService-jdks/jdk" + version)
assert jdkDir.exists()

def releaseFileText = new File(jdkDir, "release").text

assert releaseFileText.contains('its a jdk trust me')

def envVarLine = " JAVA_${version}_HOME: \"service/myService-1.0.0-jdks/jdk${version}\""
def envVarLine = " JAVA_${version}_HOME: \"service/myService-jdks/jdk${version}\""
assert launcherStatic.contains(envVarLine)
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ class JdksInDistsIntegrationSpec extends IntegrationSpec {

// A way of fixing this tests seems to open up the possibility of making extra unnecessary JDK repos - ensure
// this does not happen.
!new File(rootDir, "service/myService-1.0.0-jdks/jdk11").exists()
!new File(rootDir, "service/myService-jdks/jdk11").exists()
}

def 'even a user clearing env does not get rid of JAVA_XX_HOME env vars'() {
Expand All @@ -169,8 +169,8 @@ class JdksInDistsIntegrationSpec extends IntegrationSpec {

def launcherStatic = new File(rootDir, "service/bin/launcher-static.yml").text

launcherStatic.contains 'JAVA_11_HOME: "service/myService-1.0.0-jdks/jdk11"'
launcherStatic.contains 'JAVA_17_HOME: "service/myService-1.0.0-jdks/jdk17"'
launcherStatic.contains 'JAVA_11_HOME: "service/myService-jdks/jdk11"'
launcherStatic.contains 'JAVA_17_HOME: "service/myService-jdks/jdk17"'
}

private File extractDist() {
Expand Down

0 comments on commit d289acd

Please sign in to comment.