timja / jenkins-gh-issues-poc-06-18

0 stars 0 forks source link

[JENKINS-59772] GlobalTool JDK installation (via extract installer) fails for JDK12 onwards #4634

Open timja opened 5 years ago

timja commented 5 years ago

When using the Global Tool Configuration to install a JDK, there are several types of installers.

If the "Extract .zip/.tar.gz" is selected, it will fail from JDK 12 onwards.

The error in the log is bellow:

Started by user unknown or anonymous
Running in Durability level: MAX_SURVIVABILITY[Pipeline] Start of Pipeline[Pipeline] nodeRunning on [Jenkins|https:///computer/(master)/] in /tmp/jenkins/[Pipeline] {[Pipeline] stage[Pipeline] { (Declarative: Tool Install)[Pipeline] toolUnpacking [https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_osx-x64_bin.tar.gz] to /opt/jenkins/tools/hudson.model.JDK/openjdk12_fails on Jenkins[Pipeline] }[Pipeline] // stage[Pipeline] }[Pipeline] // node[Pipeline] End of Pipelinejava.nio.file.NoSuchFileException: /opt/jenkins/tools/hudson.model.JDK/openjdk12_fails/./jdk-12.0.2.jdk/Contents/Home/lib/server/classes.jsa
 at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
    at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
    at java.nio.file.Files.newOutputStream(Files.java:216)
    at hudson.util.IOUtils.copy(IOUtils.java:42)
    at hudson.FilePath.readFromTar(FilePath.java:2579)
Caused: java.io.IOException: Failed to extract input stream
    at hudson.FilePath.readFromTar(FilePath.java:2589)
    at hudson.FilePath.access$500(FilePath.java:212)
    at hudson.FilePath$UntarFrom.invoke(FilePath.java:812)
    at hudson.FilePath$UntarFrom.invoke(FilePath.java:803)
    at hudson.FilePath.act(FilePath.java:1076)
    at hudson.FilePath.act(FilePath.java:1059)
    at hudson.FilePath.untarFrom(FilePath.java:798)
    at hudson.FilePath.installIfNecessaryFrom(FilePath.java:930)
Caused: java.io.IOException: Failed to unpack 
[https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_osx-x64_bin.tar.gz]
 (183950127 bytes read of total 190273787)
    at hudson.FilePath.installIfNecessaryFrom(FilePath.java:932)
Caused: java.io.IOException: Failed to install 
[https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_osx-x64_bin.tar.gz]
 to /opt/jenkins/tools/hudson.model.JDK/openjdk12_fails
    at hudson.FilePath.installIfNecessaryFrom(FilePath.java:938)
    at hudson.FilePath.installIfNecessaryFrom(FilePath.java:846)
    at hudson.tools.ZipExtractionInstaller.performInstallation(ZipExtractionInstaller.java:83)
    at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:69)
    at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:109)
    at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:206)
    at hudson.model.JDK.forNode(JDK.java:147)
    at hudson.model.JDK.forNode(JDK.java:60)
    at org.jenkinsci.plugins.workflow.steps.ToolStep$Execution.run(ToolStep.java:152)
    at org.jenkinsci.plugins.workflow.steps.ToolStep$Execution.run(ToolStep.java:133)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

In order to reproduce it, the bellow code can be used:

pipeline {
    agent { node { label 'master' } }
    tools {
jdk "openjdk12"
    }
    stages {
stage('Build') {
    steps {
sh "echo Hello World"
    }
}
    }
}

And the Global tool configuration should be configured as per the attached image.


Originally reported by knyvel, imported from: GlobalTool JDK installation (via extract installer) fails for JDK12 onwards
  • status: Reopened
  • priority: Minor
  • resolution: Unresolved
  • imported: 2022/01/10
timja commented 5 years ago

knyvel:

The issue is caused, due to the existence of the classes.jsa file, introduced after JDK11. The unzipping process will abort, as soon as it reaches this file.

It does not matter the location/content of the classes.jsa file inside the zip - i tested several combinations; as soon as the file is renamed to something else, the unzipping will work.

timja commented 5 years ago

danielbeck:

Running

docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:2.190.1 

and this pipeline (different tool name, got that one wrong in tool config), produces

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/pl
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Tool Install)
[Pipeline] tool
Unpacking https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_osx-x64_bin.tar.gz to /var/jenkins_home/tools/hudson.model.JDK/jdk12 on Jenkins
[Pipeline] envVarsForTool
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ echo Hello World
Hello World
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS 

Indicating the problem here is likely environmental.

timja commented 5 years ago

danielbeck:

Also retried it on the host Mac OS system, and got

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /Users/danielbeck/Jenkins/Homes/jdk-home/workspace/pl
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Tool Install)
[Pipeline] tool
Unpacking https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_osx-x64_bin.tar.gz to /Users/danielbeck/Jenkins/Homes/jdk-home/tools/hudson.model.JDK/openjdk12 on Jenkins
[Pipeline] envVarsForTool
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ echo Hello World
Hello World
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS 
timja commented 3 years ago

alexanderu:

We have that problem periodically when our agents dinamically deployed in openshift. 

Jenkins 2.235.5, kubernetes plugin 1.27.5

13:37:35  [withMaven] using JDK installation openjdk-1.8.0-linux
13:37:35  Unpacking https://somelocalnexus/jenkins/openjdk-1.8.0-linux.tar.gz to /home/jenkins/agent/tools/hudson.model.JDK/openjdk-1.8.0-linux on massive-os-6f51l
13:37:40  ERROR: Failed to download https://somelocalnexus/jenkins/openjdk-1.8.0-linux.tar.gz from agent; will retry from master
13:37:40  java.nio.file.NoSuchFileException: /home/jenkins/agent/tools/hudson.model.JDK/openjdk-1.8.0-linux/openjdk-1.8.0/jre/lib/amd64/server/classes.jsa
13:37:40     at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
13:37:40     at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
13:37:40     at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
13:37:40     at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
13:37:40     at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
13:37:40     at java.nio.file.Files.newOutputStream(Files.java:216)
13:37:40     at hudson.util.IOUtils.copy(IOUtils.java:42)
13:37:40     at hudson.FilePath.readFromTar(FilePath.java:2602)
13:37:40  Caused: java.io.IOException: Failed to extract input stream
13:37:40     at hudson.FilePath.readFromTar(FilePath.java:2612)
13:37:40     at hudson.FilePath.access$500(FilePath.java:211)
13:37:40     at hudson.FilePath$Unpack.invoke(FilePath.java:954)
13:37:40  Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from somelocaljenkins/somelocalip:47420
13:37:40    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1788)
13:37:40    at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
13:37:40    at hudson.remoting.Channel.call(Channel.java:998)
13:37:40    at hudson.FilePath.act(FilePath.java:1069)
13:37:40    at hudson.FilePath.act(FilePath.java:1058)
13:37:40    at hudson.FilePath.installIfNecessaryFrom(FilePath.java:914)
13:37:40    at hudson.FilePath.installIfNecessaryFrom(FilePath.java:850)
13:37:40    at hudson.tools.ZipExtractionInstaller.performInstallation(ZipExtractionInstaller.java:83)
13:37:40    at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:69)
13:37:40    at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:109)
13:37:40    at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:206)
13:37:40    at hudson.model.JDK.forNode(JDK.java:148)
13:37:40    at org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution2.setupJDK(WithMavenStepExecution2.java:290)
13:37:40    at org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution2.doStart(WithMavenStepExecution2.java:194)
13:37:40    at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution.lambda$run$0(GeneralNonBlockingStepExecution.java:77)
13:37:40    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
13:37:40    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
13:37:40    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
13:37:40    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
13:37:40  Caused: java.io.IOException: Failed to unpack https://somelocalnexus/jenkins/openjdk-1.8.0-linux.tar.gz (53804998 bytes read)
13:37:40     at hudson.FilePath$Unpack.invoke(FilePath.java:957)
13:37:40     at hudson.FilePath$Unpack.invoke(FilePath.java:942)
13:37:40     at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3073)
13:37:40     at hudson.remoting.UserRequest.perform(UserRequest.java:211)
13:37:40     at hudson.remoting.UserRequest.perform(UserRequest.java:54)
13:37:40     at hudson.remoting.Request$2.run(Request.java:369)
13:37:40     at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
13:37:40     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
13:37:40     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
13:37:40     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
13:37:40     at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:97)
13:37:40     at java.lang.Thread.run(Thread.java:748)
[Pipeline] // withMaven
[Pipeline] }
[Pipeline] // nodejs