提交 6fe31014 编写于 作者: B bhenderson

Fix advertised JNLP Port

As far as I can figure, the /TcpSlaveAgentListener/ endpoint headers
tell the slaves what the JNLP port is. When I'm running jenkins behind a
proxy (marathon using the mesos plugin, which bridged networking), even
though I was setting the advertised port per a thread[1], it was not
accurately being returned in the header. This patch fixes that.

[1] https://groups.google.com/d/topic/jenkins-mesos/qUrXpDY07TQ/discussion
上级 a5bede84
......@@ -1925,7 +1925,7 @@ public class Functions {
TcpSlaveAgentListener tal = j.tcpSlaveAgentListener;
if (tal !=null) {
int p = TcpSlaveAgentListener.CLI_PORT !=null ? TcpSlaveAgentListener.CLI_PORT : tal.getPort();
int p = tal.getAdvertisedPort();
rsp.setIntHeader("X-Hudson-CLI-Port", p);
rsp.setIntHeader("X-Jenkins-CLI-Port", p);
rsp.setIntHeader("X-Jenkins-CLI2-Port", p);
......
......@@ -94,6 +94,13 @@ public final class TcpSlaveAgentListener extends Thread {
return serverSocket.socket().getLocalPort();
}
/**
* Gets the TCP port number in which we are advertising.
*/
public int getAdvertisedPort() {
return CLI_PORT != null ? CLI_PORT : getPort();
}
@Override
public void run() {
try {
......
......@@ -28,8 +28,8 @@ THE SOFTWARE.
Publicize the TCP port number for JNLP slave agents so that they know where to conenct.
Keep the legacy header for better backward compatibility
-->
<st:header name="X-Hudson-JNLP-Port" value="${app.tcpSlaveAgentListener.port}" />
<st:header name="X-Jenkins-JNLP-Port" value="${app.tcpSlaveAgentListener.port}" />
<st:header name="X-Hudson-JNLP-Port" value="${app.tcpSlaveAgentListener.advertisedPort}" />
<st:header name="X-Jenkins-JNLP-Port" value="${app.tcpSlaveAgentListener.advertisedPort}" />
<!--
if the host name is overriden, advertise that as well
-->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册