Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48538

Random NullPointerException in SSHLauncher.isRecoverable when launching agent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • ssh-slaves-plugin
    • None

      I have a script which does the following:

      1) Toggle slave to temporarilyOffline = true

      2) Spin up the slave machine

      3) Launch the agent with /launchSlaveAgent POST call

      4) Wait for the agent to be connected

      5) Toggle the slave to temporarilyOffline = false

      On step 4) sometimes happens that I get the following error:

       

      Agent successfully connected and online
      null
      ERROR: Unexpected error in launching a slave. This is probably a bug in Jenkins.
      java.lang.NullPointerException
          at hudson.plugins.sshslaves.SSHLauncher.isRecoverable(SSHLauncher.java:1332)
          at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1302)
          at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:804)
          at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:793)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)
      [12/13/17 11:31:02] [SSH] Opening SSH connection to 1.1.1.1:22.
      ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
      java.util.concurrent.CancellationException
          at java.util.concurrent.FutureTask.report(FutureTask.java:121)
          at java.util.concurrent.FutureTask.get(FutureTask.java:192)
          at hudson.plugins.sshslaves.SSHLauncher.launch(SSHLauncher.java:852)
          at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:285)
          at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)
      

      Why would it state 

      Agent successfully connected and online

      and immediately after throw NPE.

      For the moment I've worked around by waiting an extra x seconds before considering the agent actually connected successfully. This seem to have done the job and prevented experiencing errors like:

      Hudson.remoting.ChannelClosedException: Remote call on slave1 failed. The channel is closing down or has closed down

      Slaves are Google Cloud CentOS 7 machines in the same network as the master.

      Jenkins version 2.94

      Jenkins SSH Slaves plugin version 1.22

       

            oleg_nenashev Oleg Nenashev
            lucanaldini Luca Naldini
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: