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

When TcpSlaveAgentListener dies it is not restarted

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • core
    • core:2.375.1
    • 2.388

      When the TCP Agent listener crashes, it prints:

      2022-12-22 01:29:20.541+0000 [id=632]	WARNING	hudson.TcpSlaveAgentListener$1#run: Connection handler failed, restarting listener
      

      However, it never seems to be restarted.

      How to Reproduce

      (thanks duemir for providing those steps)

      It can be reproduced with a debugger (at least an IntelliJ one)

      • Start a 2.375.1 Jenkins instance with debugger enabled
      • Prepare the IDE
      • Checkout tag jenkins-2.375.1 from the jenkinsci/jenkins repo
      • Open hudson.TcpSlaveAgentListener
      • Set breakpoint somewhere in the run method of the ConnectionHandler (line 279)
      • Enable the TCP port
      • Set up an inbound agent and test that it connects
      • Connect the debugger to the controller
      • Use Throw an exception to throw some exception that is not handled in the run, e.g. new IllegalStateException("BOOM")

      As a result, something similar to the lines below should be printed in the controller logs

      2022-12-22 01:29:20.540+0000 [id=632]	SEVERE	h.TcpSlaveAgentListener$ConnectionHandler#lambda$new$0: Uncaught exception in TcpSlaveAgentListener ConnectionHandler Thread[TCP agent connection handler #6 with /127.0.0.1:61392,5,main]
      java.lang.IllegalStateException: BOOM
      	at hudson.TcpSlaveAgentListener$ConnectionHandler.run(TcpSlaveAgentListener.java:280)
      2022-12-22 01:29:20.541+0000 [id=632]	WARNING	hudson.TcpSlaveAgentListener$1#run: Connection handler failed, restarting listener
      java.lang.IllegalStateException: BOOM
      	at hudson.TcpSlaveAgentListener$ConnectionHandler.run(TcpSlaveAgentListener.java:280)
      

      May need to fiddle a bit with a breakpoint (it didn't work the first time for me for some reason. I ended up with a breakpoint that only suspended a Thread, and I had to do the "Throw exception" action twice)

      Expected: As the log says, the TCP Agent listener is restarted after the crash
      Actual: It is not. The Port is not up, and agents cannot connect.

      The workaround is to disable the port and then enable it again.

            allan_burdajewicz Allan BURDAJEWICZ
            allan_burdajewicz Allan BURDAJEWICZ
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: