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

libvirt-slave-plugin prevents Jenkins from restarting because of java.lang.NullPointerExcetion

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • libvirt-slave-plugin
    • None
    • Jenkins 2.19.4, libvirt-slave-plugin 1.8.5

      Jenkins fails to restart when libvirt-slave-plugin 1.8.5 is installed. Logfile contains the following lines:

      Dec 26, 2016 4:04:44 AM jenkins.model.Jenkins cleanUp
      INFO: Stopping Jenkins
      Dec 26, 2016 4:04:44 AM jenkins.model.Jenkins$21 onAttained
      INFO: Started termination
      Dec 26, 2016 4:04:44 AM jenkins.model.Jenkins$21 onAttained
      INFO: Completed termination
      Dec 26, 2016 4:04:44 AM jenkins.model.Jenkins _cleanUpDisconnectComputers
      INFO: Starting node disconnection
      Dec 26, 2016 4:04:44 AM jenkins.model.Jenkins$22 run
      WARNING: Could not disconnect hudson.plugins.libvirt.VirtualMachineSlaveComputer@17dc390b: null
      java.lang.NullPointerException
      at hudson.plugins.libvirt.VirtualMachineSlaveComputer.disconnect(VirtualMachineSlaveComputer.java:59)
      at jenkins.model.Jenkins$22.run(Jenkins.java:3296)
      at hudson.model.Queue._withLock(Queue.java:1303)
      at hudson.model.Queue.withLock(Queue.java:1180)
      at jenkins.model.Jenkins._cleanUpDisconnectComputers(Jenkins.java:3289)
      at jenkins.model.Jenkins.cleanUp(Jenkins.java:3165)
      at hudson.lifecycle.UnixLifecycle.restart(UnixLifecycle.java:70)
      at jenkins.model.Jenkins$26.run(Jenkins.java:4145)

      Dec 26, 2016 4:04:44 AM jenkins.model.Jenkins$22 run
      WARNING: Could not disconnect hudson.plugins.libvirt.VirtualMachineSlaveComputer@6344b0b7: null
      java.lang.NullPointerException
      at hudson.plugins.libvirt.VirtualMachineSlaveComputer.disconnect(VirtualMachineSlaveComputer.java:59)
      at jenkins.model.Jenkins$22.run(Jenkins.java:3296)
      at hudson.model.Queue._withLock(Queue.java:1303)
      at hudson.model.Queue.withLock(Queue.java:1180)
      at jenkins.model.Jenkins._cleanUpDisconnectComputers(Jenkins.java:3289)
      at jenkins.model.Jenkins.cleanUp(Jenkins.java:3165)
      at hudson.lifecycle.UnixLifecycle.restart(UnixLifecycle.java:70)
      at jenkins.model.Jenkins$26.run(Jenkins.java:4145)

      Dec 26, 2016 4:04:44 AM jenkins.model.Jenkins$22 run
      WARNING: Could not disconnect hudson.plugins.libvirt.VirtualMachineSlaveComputer@39bc8ceb: null
      java.lang.NullPointerException
      at hudson.plugins.libvirt.VirtualMachineSlaveComputer.disconnect(VirtualMachineSlaveComputer.java:59)
      at jenkins.model.Jenkins$22.run(Jenkins.java:3296)
      at hudson.model.Queue._withLock(Queue.java:1303)
      at hudson.model.Queue.withLock(Queue.java:1180)
      at jenkins.model.Jenkins._cleanUpDisconnectComputers(Jenkins.java:3289)
      at jenkins.model.Jenkins.cleanUp(Jenkins.java:3165)
      at hudson.lifecycle.UnixLifecycle.restart(UnixLifecycle.java:70)
      at jenkins.model.Jenkins$26.run(Jenkins.java:4145)

      Dec 26, 2016 4:04:44 AM jenkins.model.Jenkins$22 run
      WARNING: Could not disconnect hudson.plugins.libvirt.VirtualMachineSlaveComputer@4a2c3c84: null
      java.lang.NullPointerException
      at hudson.plugins.libvirt.VirtualMachineSlaveComputer.disconnect(VirtualMachineSlaveComputer.java:59)
      at jenkins.model.Jenkins$22.run(Jenkins.java:3296)
      at hudson.model.Queue._withLock(Queue.java:1303)
      at hudson.model.Queue.withLock(Queue.java:1180)
      at jenkins.model.Jenkins._cleanUpDisconnectComputers(Jenkins.java:3289)
      at jenkins.model.Jenkins.cleanUp(Jenkins.java:3165)
      at hudson.lifecycle.UnixLifecycle.restart(UnixLifecycle.java:70)
      at jenkins.model.Jenkins$26.run(Jenkins.java:4145)
      Dec 26, 2016 4:04:44 AM jenkins.model.Jenkins$26 run
      WARNING: Failed to restart Jenkins
      java.lang.RuntimeException: Unexpected issues encountered during cleanUp: null; null; null; null
      at jenkins.model.Jenkins.cleanUp(Jenkins.java:3202)
      at hudson.lifecycle.UnixLifecycle.restart(UnixLifecycle.java:70)
      at jenkins.model.Jenkins$26.run(Jenkins.java:4145)
      Suppressed: java.lang.NullPointerException
      at hudson.plugins.libvirt.VirtualMachineSlaveComputer.disconnect(VirtualMachineSlaveComputer.java:59)
      at jenkins.model.Jenkins$22.run(Jenkins.java:3296)
      at hudson.model.Queue._withLock(Queue.java:1303)
      at hudson.model.Queue.withLock(Queue.java:1180)
      at jenkins.model.Jenkins._cleanUpDisconnectComputers(Jenkins.java:3289)
      at jenkins.model.Jenkins.cleanUp(Jenkins.java:3165)
      ... 2 more
      Suppressed: java.lang.NullPointerException
      at hudson.plugins.libvirt.VirtualMachineSlaveComputer.disconnect(VirtualMachineSlaveComputer.java:59)
      at jenkins.model.Jenkins$22.run(Jenkins.java:3296)
      at hudson.model.Queue._withLock(Queue.java:1303)
      at hudson.model.Queue.withLock(Queue.java:1180)
      at jenkins.model.Jenkins._cleanUpDisconnectComputers(Jenkins.java:3289)
      at jenkins.model.Jenkins.cleanUp(Jenkins.java:3165)
      ... 2 more
      Suppressed: java.lang.NullPointerException
      at hudson.plugins.libvirt.VirtualMachineSlaveComputer.disconnect(VirtualMachineSlaveComputer.java:59)
      at jenkins.model.Jenkins$22.run(Jenkins.java:3296)
      at hudson.model.Queue._withLock(Queue.java:1303)
      at hudson.model.Queue.withLock(Queue.java:1180)
      at jenkins.model.Jenkins._cleanUpDisconnectComputers(Jenkins.java:3289)
      at jenkins.model.Jenkins.cleanUp(Jenkins.java:3165)
      ... 2 more
      Caused by: java.lang.NullPointerException
      at hudson.plugins.libvirt.VirtualMachineSlaveComputer.disconnect(VirtualMachineSlaveComputer.java:59)
      at jenkins.model.Jenkins$22.run(Jenkins.java:3296)
      at hudson.model.Queue._withLock(Queue.java:1303)
      at hudson.model.Queue.withLock(Queue.java:1180)
      at jenkins.model.Jenkins._cleanUpDisconnectComputers(Jenkins.java:3289)
      at jenkins.model.Jenkins.cleanUp(Jenkins.java:3165)
      ... 2 more

      Root cause:

      jenkins.model.Jenkins object enumerates over all hudson.model.Computer instances and calls hudson.model.Computer.disconnect() method with argument cause=null (line 3296). But method hudson.plugins.libvirt.VirtualMachineSlaveComputer.disconnect() doesn't expect cause argument to be null (line 59). As a result, Java raises java.lang.NullPointerException because of null pointer dereference.

      jenkins.model.Jenkins:run() method near line 3296:

                      for( Computer c : computers.values() ) {
                          try {
                              c.interrupt();
                              killComputer(c);
                              pending.add(c.disconnect(null)); // <----------line 3296: call disconnect() with cause=null
                          } catch (OutOfMemoryError e) {
      

      hudson.plugins.libvirt.VirtualMachineSlaveComputer:disconnect() method near line 59:

      	@Override
      	public Future<?> disconnect(OfflineCause cause) {
      		VirtualMachineSlave slave = (VirtualMachineSlave) getNode();
      		String virtualMachineName = slave.getVirtualMachineName();
      		VirtualMachineLauncher vmL = (VirtualMachineLauncher) getLauncher();
      		Hypervisor hypervisor = vmL.findOurHypervisorInstance();
      		logger.log(Level.INFO, "Virtual machine \"" + virtualMachineName + "\" (slave \"" + getDisplayName() + "\") is to be shut down. reason: "+cause+" ("+cause.getClass().getName()+")"); // <-------- line 59: cause.getClass() raises exception, as cause=null
      		taskListener.getLogger().println("Virtual machine \"" + virtualMachineName + "\" (slave \"" + getDisplayName() + "\") is to be shut down.");
      

            bgermann Bastian Germann
            fsv Siarhei Farbotka
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: