Jenkins 无法识别 slave 处于关闭状态,因此不允许它重新连接

Jenkins doesn't recognize slave being down and thus does not allow for it to reconnect

我们在 Ubuntu 上有一个 Jenkins 实例 运行,它在不同的系统中有多个从属。其中之一是 Windows 7 主机,将 jenkins slave 实例配置为服务。

我们遇到了一个问题,当那台机器重新启动时,Jenkins 大师并没有意识到它已经消失了。它在节点视图中看起来很好。然后,当发出应该使用该从站的构建时,它会卡住。如果停止,下一次构建会立即失败

Caused by: java.util.concurrent.TimeoutException: Ping started at 1457016721684 hasn't completed by 1457016961684
    ... 2 more
[EnvInject] - [ERROR] - SEVERE ERROR occurs: channel is already closed

当从站启动并尝试连接回主站时,连接被拒绝,并且在日志中有一个错误,指出该名称的连接已经存在:

Server didn't accept the handshake: xxx is already connected to this master. Rejecting this connection.

存在问题 JENKINS-5055 which claims a fix was committed allowing the same JNLP slave to reconnect without getting rejected, apparently this commit, and according to changelog, it was introduced in version 1.396 (2011/02/02). We are however using version 1.639 and seeing this. Somebody else seems to be seeing it as well. By looking at current codebase, I see where the error is coming from,但未在 Jenkins-5055 中看到修复。

有解决这个问题的想法吗?

编辑:也asked on jenkins user mailing list,但没有回复。

我们遇到了同样的问题。使用 https://wiki.jenkins-ci.org/display/JENKINS/slave-status 作为解决方法

在 Windows Server 2012 R2 机器上重新安装从属服务器没有出现这种行为的迹象,因此似乎是在安装步骤中出错或者这是使用工作站造成的Windows版本。

无论如何,这里是让它工作的步骤,假设是 Windows 的全新安装,没有网络连接,主实例使用自签名证书:

  1. 在机器上安装JRE。如果您有 64 位操作系统,请同时安装 32 位和 64 位操作系统,否则请安装 32 位操作系统。下载 link here
  2. 在机器上安装 .NET 3.5。这是 Jenkins 服务所需要的。为此,您可以按照 my other answer 概述的步骤进行操作。
  3. 使用 Windows 安装程序 (.zipped) 将 Jenkins 安装到 C:\Jenkins。可以从 here.
  4. 下载
  5. 通过导航至 http://localhost:8080 检查您的安装是否有响应。如果遇到问题,请检查 jenkins 文件夹中的日志。如果存在端口冲突,请编辑 jenkins.xml 并将 httpPort 更改为其他内容。
  6. 从 Windows 计算机,导航到您的 master jenkins 并在那里配置一个新节点。
  7. 在配置 -> 节点屏幕中使用 Java 启动代理启动从属代理(您需要仍在使用您的 Windows 从属计算机)
  8. 您应该会看到一个可见的 window 开口。从那里,select 文件 -> 安装为服务。 (details and screenshots) If you experience an error without proper explanation, confirm .NET 3.5 is properly installed. If you see "WMI.WmiException: AccessDenied", save the jnlp file locally and start it from administrator prompt or otherwise with elevated privileges (details).
  9. 从“管理工具”->“服务”中,停止并禁用 Jenkins 服务,然后停止 Jenkins Slave Agent 但将其保留为“自动”,以便在启动计算机时启动。
  10. 这仅在您使用自签名证书或有问题的证书时才有意义:
    1. 再次下载前面提到的JavaLaunch Agent文件(.jnlp文件)并保存到C:\jenkins
    2. 向您的编辑器打开 c:\jenkins\jenkins-slave.xml
    3. 通过更改 jnlp url 参数 (file:/C:/jenkins/jenkins-slave.jnlp)
    4. 将其更改为引用本地 .jnlp 文件
    5. 在参数中添加 -noCertificateCheck
    6. 将 -secret 参数替换为 -auth "user:pass",否则将添加自动 url get 参数,这将导致无法找到 .jnlp 文件
  11. 再次启动Jenkins Slave Agent服务

关于 jenkins slave 服务的问题,查看 jenkins-slave.err.log。对于 Windows Server 2012 R2,您可以在 Powershell 提示符下使用 Get-Content .\jenkins-slave.err.log -Wait -Tail 10 来获取 tail 的功能。对于旧版本的 Powershell,省略 -Tail 10.