Bug 1034430

Summary: Jenkins server can not download JDK from other sites
Product: OpenShift Online Reporter: Misho Krastev <misho_kr>
Component: ImageAssignee: Ben Parees <bparees>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 2.xCC: agoldste, ccoleman, chunchen, dmcphers, mfojtik
Target Milestone: ---Keywords: UpcomingRelease
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-18 16:49:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Misho Krastev 2013-11-25 20:13:25 UTC
Description of problem:

Jenkins server can not be set up to download and use JDK from Oracle site. 

Jenkins allows to configure custom JDK  version to be used for builds. But it does not work on OpenShift Online with the Jenkins cartridge. Without changing the JDK setting, a simple NodeJS app (no user-provided code, just the template code) can be built with Jenkins without any problems, but if Jenkins is configured to use custom JDK -- for example the latest 7u45 from the dropdown box, the build fails. 

Version-Release number of selected component (if applicable):


How reproducible:

Always

Steps to Reproduce:
1. Create Jenkins server
2. Create NodeJS app (v 0.10) and then enable Jenkins builds
3. Login to Jenkins server, click on Jenkins > Manage Jenkins > Configure System
4. Click on "Add JDK" button, enter "JDK7u45" as Name, check the box "I agree to the ..."
5. Click on "Please enter your username/password" and enter valid Oracle OTN credentials
6. Save the modified Jenkins configuration
7. Navigate to the build project for the node app and click on "Build Now"

Actual results:

Build fails when Jenkins attempts to download JDK from the Oracle site.

Expected results:

Jenkins should be able to download, install custom JDK and use it to perform the build.

Additional info:

Here is the entire build log.

Started by user Jenkins Admin
Building remotely on nodejsbldrInstalling JDK jdk-7u45-oth-JPR
Downloading JDK from http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-i586.tar.gz
FATAL: Permission denied
java.net.BindException: Permission denied
	at java.net.PlainSocketImpl.socketBind(Native Method)
	at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
	at java.net.Socket.bind(Socket.java:627)
	at java.net.Socket.<init>(Socket.java:423)
	at java.net.Socket.<init>(Socket.java:280)
	at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
	at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
	at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
	at hudson.tools.JDKInstaller.locate(JDKInstaller.java:381)
	at hudson.tools.JDKInstaller.performInstallation(JDKInstaller.java:125)
	at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:61)
	at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:107)
	at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:203)
	at hudson.model.JDK.forNode(JDK.java:122)
	at hudson.model.AbstractProject.getEnvironment(AbstractProject.java:336)
	at hudson.model.Run.getEnvironment(Run.java:2040)
	at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:931)
	at hudson.model.AbstractBuild$AbstractBuildExecution.decideWorkspace(AbstractBuild.java:547)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:567)
	at hudson.model.Run.execute(Run.java:1575)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
	at hudson.model.ResourceController.execute(ResourceController.java:88)
	at hudson.model.Executor.run(Executor.java:237)

Comment 1 Michal Fojtik 2013-11-26 14:26:32 UTC
Moving to Jakub as he is working on this one right now.

Comment 2 Ben Parees 2014-02-10 21:42:21 UTC
I expect we're hitting the same issue here as some users have:
https://www.openshift.com/forums/openshift/commons-httpclient-permission-denied

Fixing this requires moving jenkins to a different level of httpclient or modifying jenkins to apply the method described to avoid doing the client side bind during socket creation.

Comment 3 Ben Parees 2014-03-06 16:41:22 UTC
This is currently a pull request against jenkins to prevent the binding:
https://github.com/jenkinsci/jenkins/pull/1134

Comment 4 Balazs Varga 2014-07-23 13:03:59 UTC
The mentioned PR merged into Jenkins, 1.560 already contains the patch[1].
At the moment (ami-86fc35ee - devenv_4998) we are using 1.554.2.

[1]: https://github.com/jenkinsci/jenkins/commits/jenkins-1.560

Comment 5 Ben Parees 2014-07-23 13:28:56 UTC
Yeah unfortunately we'll have to wait for the next LTS.  I was really hoping my PR was going to have made the 1.554 LTS.

Comment 6 Ben Parees 2014-10-07 16:49:57 UTC
now that we've moved to LTS 1.565 this works.

note that you need to be on the latest jenkins plugin also:

jenkins-plugin-openshift-0.6.40-0.el6oso.x86_64
jenkins-1.565.3-1.el6oso.noarch

Comment 7 chunchen 2014-10-08 06:58:02 UTC
It's fixed, verified on devenv_5219, please refer to the following results:

1. Create Jenkins server
2. Create NodeJS app (v 0.10) and then enable Jenkins builds
3. Login to Jenkins server, click on Jenkins > Manage Jenkins > Configure System
4. Click on "Add JDK" button, enter "JDK7u45" as Name, check the box "I agree to the ..."
5. Click on "Please enter your username/password" and enter valid Oracle OTN credentials
6. Save the modified Jenkins configuration
7. Navigate to the build project for the node app and click on "Build Now"

### Console Output ###
Started by user Jenkins Admin
Building remotely on cndjs10bldr (cndjs10-build)Installing JDK jdk-8u20-oth-JPR
Downloading JDK from http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-i586.tar.gz
Downloading 162389708bytes

Installing /var/lib/openshift/5435169f89968e200a000003/app-root/data/jenkins/tools/hudson.model.JDK/JDK7u45/jdk.sh
[JDK7u45] $ tar xvzf /var/lib/openshift/5435169f89968e200a000003/app-root/data/jenkins/tools/hudson.model.JDK/JDK7u45/jdk.sh
jdk1.8.0_20/
jdk1.8.0_20/THIRDPARTYLICENSEREADME.txt
jdk1.8.0_20/src.zip
jdk1.8.0_20/man/
jdk1.8.0_20/man/ja_JP.UTF-8/
jdk1.8.0_20/man/ja_JP.UTF-8/man1/
jdk1.8.0_20/man/ja_JP.UTF-8/man1/jjs.1
jdk1.8.0_20/man/ja_JP.UTF-8/man1/jstatd.1
jdk1.8.0_20/man/ja_JP.UTF-8/man1/javadoc.1
<-----------snip----------->
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/profileRegistry/JMC.profile/
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/profileRegistry/JMC.profile/1404825663150.profile.gz
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/profileRegistry/JMC.profile/1404825662298.profile.gz
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/profileRegistry/JMC.profile/1404825681769.profile.gz
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/profileRegistry/JMC.profile/.data/
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/profileRegistry/JMC.profile/1404825678426.profile.gz
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/profileRegistry/JMC.profile/.lock
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/.settings/
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/.settings/org.eclipse.equinox.p2.artifact.repository.prefs
jdk1.8.0_20/lib/missioncontrol/p2/org.eclipse.equinox.p2.engine/.settings/org.eclipse.equinox.p2.metadata.repository.prefs
jdk1.8.0_20/lib/missioncontrol/mc.jar
jdk1.8.0_20/lib/missioncontrol/libcairo-swt.so
jdk1.8.0_20/lib/missioncontrol/dropins/
jdk1.8.0_20/lib/missioncontrol/dropins/README.TXT
jdk1.8.0_20/lib/ant-javafx.jar
jdk1.8.0_20/lib/dt.jar
jdk1.8.0_20/javafx-src.zip
jdk1.8.0_20/release
jdk1.8.0_20/LICENSE
jdk1.8.0_20/README.html
jdk1.8.0_20/db/
jdk1.8.0_20/db/lib/
jdk1.8.0_20/db/lib/derbyLocale_zh_TW.jar
jdk1.8.0_20/db/lib/derbyLocale_it.jar
jdk1.8.0_20/db/lib/derbyLocale_pt_BR.jar
jdk1.8.0_20/db/lib/derbyLocale_es.jar
jdk1.8.0_20/db/lib/derbyLocale_fr.jar
jdk1.8.0_20/db/lib/derbyLocale_pl.jar
jdk1.8.0_20/db/lib/derby.war
jdk1.8.0_20/db/lib/derbyLocale_zh_CN.jar
<-------------snip----------->
jdk1.8.0_20/bin/javac
jdk1.8.0_20/bin/javapackager
jdk1.8.0_20/bin/jmap
jdk1.8.0_20/bin/tnameserv
jdk1.8.0_20/bin/unpack200
jdk1.8.0_20/bin/jstack
jdk1.8.0_20/bin/wsimport
jdk1.8.0_20/bin/idlj
jdk1.8.0_20/bin/xjc
jdk1.8.0_20/include/
jdk1.8.0_20/include/jdwpTransport.h
jdk1.8.0_20/include/jni.h
jdk1.8.0_20/include/jawt.h
jdk1.8.0_20/include/jvmticmlr.h
jdk1.8.0_20/include/jvmti.h
jdk1.8.0_20/include/linux/
jdk1.8.0_20/include/linux/jawt_md.h
jdk1.8.0_20/include/linux/jni_md.h
jdk1.8.0_20/include/classfile_constants.h
jdk1.8.0_20/COPYRIGHT
jdk1.8.0_20/jre/
jdk1.8.0_20/jre/THIRDPARTYLICENSEREADME.txt
jdk1.8.0_20/jre/lib/
jdk1.8.0_20/jre/lib/psfont.properties.ja
jdk1.8.0_20/jre/lib/deploy/
jdk1.8.0_20/jre/lib/deploy/splash.gif
jdk1.8.0_20/jre/lib/deploy/mixcode_s.png
jdk1.8.0_20/jre/lib/deploy/messages_zh_HK.properties
<-----------snip-------->
Building git ref 'origin/HEAD', commit c3bac2b
Building NodeJS cartridge

npm info it worked if it ends with ok
npm info using npm.24
npm info using node.25
npm info preinstall OpenShift-Sample-App.0
npm info trying registry request attempt 1 at 06:50:45
npm http GET https://registry.npmjs.org/express

npm http 200 https://registry.npmjs.org/express
<--------------snip---------->
npm info ok 
+ /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh 54351354e72d9b79500002bb.rhcloud.com 'gear stop --conditional --exclude-web-proxy --git-ref c3bac2b0a8742d734abca82fcef35e6701bf8986'

Stopping gear...

Stopping NodeJS cartridge
Wed Oct 08 2014 06:50:59 GMT-0400 (EDT): Stopping application 'cndjs10' ...
Wed Oct 08 2014 06:50:59 GMT-0400 (EDT): Stopped Node application 'cndjs10'
++ /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh 54351354e72d9b79500002bb.rhcloud.com 'gear create-deployment-dir'

+ deployment_dir=2014-10-08_06-51-02.220
+ rsync --delete-after -azS -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh /var/lib/openshift/5435169f89968e200a000003//app-deployments/current/metadata.json 54351354e72d9b79500002bb.rhcloud.com:app-deployments/2014-10-08_06-51-02.220/metadata.json

+ rsync --delete-after -azS -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh --exclude .git /var/lib/openshift/5435169f89968e200a000003/app-root/runtime/repo/ 54351354e72d9b79500002bb.rhcloud.com:app-root/runtime/repo/

+ rsync --delete-after -azS -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh /var/lib/openshift/5435169f89968e200a000003/app-root/runtime/build-dependencies/ 54351354e72d9b79500002bb.rhcloud.com:app-root/runtime/build-dependencies/

+ rsync --delete-after -azS -e /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh /var/lib/openshift/5435169f89968e200a000003/app-root/runtime/dependencies/ 54351354e72d9b79500002bb.rhcloud.com:app-root/runtime/dependencies/

+ /usr/libexec/openshift/cartridges/jenkins/bin/git_ssh_wrapper.sh 54351354e72d9b79500002bb.rhcloud.com 'gear remotedeploy --deployment-datetime 2014-10-08_06-51-02.220'

Preparing build for deployment

Deployment id is 98b79349
Activating deployment

Starting NodeJS cartridge
Wed Oct 08 2014 06:51:13 GMT-0400 (EDT): Starting application 'cndjs10' ...

Archiving artifacts

Finished: SUCCESS