Windows-Server-2012

Jenkins Slave 在建構期間離線

  • April 28, 2022

在 Windows Server 2012 上安裝了 Jenkins 1.651 master 和 slave。slave 專用於執行 Selenium 測試,但大多數時候它會離線:

Build step 'Execute Windows batch command' marked build as failure
ERROR: slave-tester is offline; cannot locate jdk7

Apr 20, 2016 2:20:05 PM INFO jenkins.slaves.DefaultJnlpSlaveReceiver handle
Disconnecting slave-tester as we are reconnected from the current peer
Apr 20, 2016 2:20:17 PM WARNING org.jenkinsci.remoting.nio.NioChannelHub run
Communication problem
java.io.IOException: An existing connection was forcibly closed by the remote host
   at sun.nio.ch.SocketDispatcher.read0(Native Method)
   at sun.nio.ch.SocketDispatcher.read(Unknown Source)
   at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
   at sun.nio.ch.IOUtil.read(Unknown Source)
   at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
   at org.jenkinsci.remoting.nio.FifoBuffer$Pointer.receive(FifoBuffer.java:136)
   at org.jenkinsci.remoting.nio.FifoBuffer.receive(FifoBuffer.java:306)
   at org.jenkinsci.remoting.nio.NioChannelHub.run(NioChannelHub.java:561)
   at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
   at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   at java.util.concurrent.FutureTask.run(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Apr 20, 2016 2:20:17 PM WARNING jenkins.slaves.JnlpSlaveAgentProtocol$Handler$1 onClosed
NioChannelHub keys=2 gen=88003: Computer.threadPoolForRemoting [#2] for slave-tester terminated
java.io.IOException: Connection aborted: org.jenkinsci.remoting.nio.NioChannelHub$MonoNioTransport@17d0b4b[name=xxx]
   at org.jenkinsci.remoting.nio.NioChannelHub$NioTransport.abort(NioChannelHub.java:208)
   at org.jenkinsci.remoting.nio.NioChannelHub.run(NioChannelHub.java:628)
   at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
   at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   at java.util.concurrent.FutureTask.run(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host
   at sun.nio.ch.SocketDispatcher.read0(Native Method)
   at sun.nio.ch.SocketDispatcher.read(Unknown Source)
   at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
   at sun.nio.ch.IOUtil.read(Unknown Source)
   at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
   at org.jenkinsci.remoting.nio.FifoBuffer$Pointer.receive(FifoBuffer.java:136)
   at org.jenkinsci.remoting.nio.FifoBuffer.receive(FifoBuffer.java:306)
   at org.jenkinsci.remoting.nio.NioChannelHub.run(NioChannelHub.java:561)
   ... 6 more

從屬日誌:

<===[JENKINS REMOTING CAPACITY]===>Slave.jar version: 2.53.3
Slave.jar version: 2.53.3
This is a Windows slave
This is a Windows slave
Connection terminated
Connection terminated
ERROR: Failed to install restarter
hudson.remoting.RequestAbortedException: hudson.remoting.Channel$OrderlyShutdown
   at hudson.remoting.Request.abort(Request.java:297)
   at hudson.remoting.Channel.terminate(Channel.java:847)
   at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1080)
   at hudson.remoting.Channel$1.handle(Channel.java:501)
   at hudson.remoting.AbstractByteArrayCommandTransport$1.handle(AbstractByteArrayCommandTransport.java:61)
   at org.jenkinsci.remoting.nio.NioChannelHub$2.run(NioChannelHub.java:594)
   at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   at java.util.concurrent.FutureTask.run(Unknown Source)
   at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
   at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
   at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   at java.util.concurrent.FutureTask.run(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
   at ......remote call to slave-tester(Native Method)
   at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
   at hudson.remoting.Request.call(Request.java:172)
   at hudson.remoting.Channel.call(Channel.java:780)
   at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller.install(JnlpSlaveRestarterInstaller.java:52)
   at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller.access$000(JnlpSlaveRestarterInstaller.java:33)
   at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$1.call(JnlpSlaveRestarterInstaller.java:39)
   at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$1.call(JnlpSlaveRestarterInstaller.java:36)
   at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
   at java.util.concurrent.FutureTask.run(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: hudson.remoting.Channel$OrderlyShutdown
   at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1080)
   at hudson.remoting.Channel$1.handle(Channel.java:501)
   at hudson.remoting.AbstractByteArrayCommandTransport$1.handle(AbstractByteArrayCommandTransport.java:61)
   at org.jenkinsci.remoting.nio.NioChannelHub$2.run(NioChannelHub.java:594)
   at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   at java.util.concurrent.FutureTask.run(Unknown Source)
   at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
   at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
   at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   ... 4 more
Caused by: Command close created at
   at hudson.remoting.Command.<init>(Command.java:56)
   at hudson.remoting.Channel$CloseCommand.<init>(Channel.java:1074)
   at hudson.remoting.Channel$CloseCommand.<init>(Channel.java:1072)
   at hudson.remoting.Channel.close(Channel.java:1156)
   at hudson.remoting.Channel.close(Channel.java:1138)
   at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1079)
   at hudson.remoting.Channel$1.handle(Channel.java:501)
   at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:60)

是什麼導致了這個問題以及如何解決它?

類似問題

可能的解決方案

基於此 source,堆棧跟踪的一部分:

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

並且在辦公室中遇到同樣的問題,將 jdk7 升級到最新的 oracle-jdk8 可以解決這個問題。

如果問題仍然存在:

  1. 請準確說明問題發生的時間,以便可以重現問題
  2. 請添加導致問題的建構的 Jenkins 建構日誌。也許有一個特定的任務由導致問題的作業執行。
  3. 建構作業時查看 windows 任務管理器
  4. 請添加成功建構之一的日誌和失敗建構之一的日誌

引用自:https://serverfault.com/questions/770260