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

When TcpSlaveAgentListener dies it is not restarted

    • 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.

          [JENKINS-70334] When TcpSlaveAgentListener dies it is not restarted

          Allan BURDAJEWICZ created issue -
          Allan BURDAJEWICZ made changes -
          Link New: This issue is related to JENKINS-59910 [ JENKINS-59910 ]
          Allan BURDAJEWICZ made changes -
          Summary Original: TcpSlaveAgentListenerRescheduler is not working properly New: When TcpSlaveAgentListener dies it is not restarted
          Allan BURDAJEWICZ made changes -
          Description Original: When the TCP Agent listener crashes, it prints:

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

          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|https://www.jetbrains.com/help/idea/altering-the-program-s-execution-flow.html#throw_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

          {code}
          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)
          {code}

          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.
          New: When the TCP Agent listener crashes, it prints:

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

          However, it never seems to be restarted.

          h3. 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|https://www.jetbrains.com/help/idea/altering-the-program-s-execution-flow.html#throw_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

          {code}
          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)
          {code}

          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 made changes -
          Assignee New: Allan BURDAJEWICZ [ allan_burdajewicz ]
          Allan BURDAJEWICZ made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Allan BURDAJEWICZ made changes -
          Remote Link New: This issue links to "jenkins #7547 (Web Link)" [ 28416 ]
          Allan BURDAJEWICZ made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          Allan BURDAJEWICZ made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Resolved [ 5 ]
          Allan BURDAJEWICZ made changes -
          Status Original: Resolved [ 5 ] New: Fixed but Unreleased [ 10203 ]

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

              Created:
              Updated: