jenkinsci / nomad-plugin

Nomad cloud plugin for Jenkins
https://plugins.jenkins.io/nomad/
MIT License
56 stars 41 forks source link

Don't always set the tunnel value. #50

Closed multani closed 5 years ago

multani commented 5 years ago

If it's not set, there must be a good reason, and NomadApi.java takes care of not passing the -tunnel option if it's empty.

I have a configuration where the Jenkins Base URL is set to http://jenkins-master.my.hostname/jenkins/, but the Jenkins Tunnel option is empty. When starting a new worker, this produces the following log:

Jun 26, 2019 4:34:27 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: jenkins-worker-builder-1f24946fc9a24
Jun 26, 2019 4:34:27 PM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Jun 26, 2019 4:34:27 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 3.33
Jun 26, 2019 4:34:27 PM hudson.remoting.Engine startEngine
WARNING: No Working Directory. Using the legacy JAR Cache location: /workspace/.jenkins/cache/jars
Jun 26, 2019 4:34:28 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://jenkins-master.my.hostname/jenkins/]
Jun 26, 2019 4:34:28 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
Jun 26, 2019 4:34:28 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting TCP connection tunneling is enabled. Skipping the TCP Agent Listener Port availability check
Jun 26, 2019 4:34:28 PM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: For input string: "//jenkins-master.my.hostname/jenkins/"
java.lang.NumberFormatException: For input string: "//jenkins-master.my.hostname/jenkins/"
    at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.base/java.lang.Integer.parseInt(Integer.java:638)
    at java.base/java.lang.Integer.parseInt(Integer.java:770)
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:331)
    at hudson.remoting.Engine.innerRun(Engine.java:523)
    at hudson.remoting.Engine.run(Engine.java:474)

There's currently a check to ensure the tunnel option is set only when actually configured but the tunnel option can never be empty (and actually filled with a value it will not understand).

I haven't tested the fix.

multani commented 5 years ago

@phedoreanu Thanks for merging this, do you think you can cut a new release with this fix?

phedoreanu commented 5 years ago

https://github.com/jenkinsci/nomad-plugin/releases/tag/v6.0.4

multani commented 5 years ago

https://github.com/jenkinsci/nomad-plugin/releases/tag/v6.0.4

:heart_eyes: