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

WebSocket agent does not reconnect: ClassNotFoundException: jenkins.slaves.restarter.JnlpSlaveRestarterInstaller

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • Jenkins: 2.303.1
      jenkins k8s controller (master) pod version: jenkins/jenkins:2.289.3-jdk11
      jenkins k8s agent (slave) pod version:  jenkins/inbound-agent:4.9-1-jdk11
      Kubernetes plugin: 1.30.1
    • Jenkins 2.338, Remoting 4.13, 2.332.2

      I'm using jenkins helm chart for my jenkins controller (master) with persistence EFS volume together with Kubernetes plugin with inbound-agent (jdk11) pods for my agents (slaves) over websocket connection

      It seems that the Agent (slave) pods are unable to re-connect the controller (master) after a reboot to the controller (master).

      It seems that the process exit with exit code 0 from some reason instead of reconnecting.

       

      jenkins controller (master) log

      2021-08-24 13:26:33.976+0000 [id=64]    INFO    o.c.j.p.k.KubernetesLauncher#launch: Agent has already been launched, activating: jenkins-agent-3q3j5
      

       

      jenkins agent (slave) log:

      Aug 24, 2021 1:23:56 PM hudson.remoting.Engine lambda$new$1
      Aug 24, 2021 1:23:56 PM hudson.remoting.Engine lambda$new$1SEVERE: Uncaught exception in Engine thread Thread[Thread-0,5,main]
      java.lang.NoClassDefFoundError: jenkins/slaves/restarter/JnlpSlaveRestarterInstaller 
          at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$FindEffectiveRestarters$1.onReconnect(JnlpSlaveRestarterInstaller.java:91) 
          at hudson.remoting.EngineListenerSplitter.onReconnect(EngineListenerSplitter.java:54) 
          at hudson.remoting.Engine.runWebSocket(Engine.java:687) 
          at hudson.remoting.Engine.run(Engine.java:496)
      Caused by: java.lang.ClassNotFoundException: jenkins.slaves.restarter.JnlpSlaveRestarterInstaller     
          at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471) 
          at hudson.remoting.RemoteClassLoader.findClass(RemoteClassLoader.java:215)   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589) 
          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 4 more
      

       

      jenkins agent (slave) pod status:

      NAME                              READY   STATUS     RESTARTS   AGE
      jenkins-agent-3q3j5               1/2     NotReady   0          15m
      
      
          lastState: {}
          name: jnlp
          ready: false
          restartCount: 0
          started: false
          state:
            terminated:
              containerID: docker://9b490eafd5078fa95cbd915bed16bcee767c1005a7a96158a2017d1551fba87b
              exitCode: 0
              finishedAt: "2021-09-08T15:00:07Z"
              reason: Completed
              startedAt: "2021-09-08T14:53:19Z"
      
      

       

       inbound-agent conf

          - name: JENKINS_SECRET
            value: 271983729187392173921798379281739821793b
          - name: JENKINS_AGENT_NAME
            value: jenkins-agent-3q3j5
          - name: DOCKER_HOST
            value: tcp://localhost:2375
          - name: JENKINS_WEB_SOCKET
            value: "true"
          - name: JAVA_OPTS
            value: -Xms512m -Xmx1500m
          - name: JENKINS_NAME
            value: jenkins-agent-3q3j5
          - name: JENKINS_AGENT_WORKDIR
            value: /home/jenkins/agent
          - name: JENKINS_URL
            value: http://jenkins:8080/
          - name: AWS_DEFAULT_REGION
            value: us-east-1
          - name: AWS_REGION
            value: us-east-1
          - name: AWS_ROLE_ARN
            value: arn:aws:iam::123456789:role/jenkins-agent-pod
          - name: AWS_WEB_IDENTITY_TOKEN_FILE
            value: /var/run/secrets/eks.amazonaws.com/serviceaccount/token
      

       

      jenkins agent (slave) pod process

      /opt/java/openjdk/bin/java -Xms512m -Xmx1500m -cp /usr/share/jenkins/agent.jar hudson.remoting.jnlp.Main -headless -url http://jenkins:8080/ -workDir /home /jenkins/agent -webSocket 271983729187392173921798379281739821793b jenkins-agent-3q3j5
      

       

      same behavior in

      jenkins/jenkins:2.303.1-jdk11
      jenkins/inbound-agent:4.10-2-jdk11
      

       

      It seems that this issue happens also on windows agent (slave)

       

      might be related: https://issues.jenkins.io/browse/JENKINS-59910

          [JENKINS-66446] WebSocket agent does not reconnect: ClassNotFoundException: jenkins.slaves.restarter.JnlpSlaveRestarterInstaller

          I am seeing the exact same behavior, however my master was not rebooted. It just happens randomly.

          Morten Birkelund added a comment - I am seeing the exact same behavior, however my master was not rebooted. It just happens randomly.

          Tim Jacomb added a comment -

          The

          java.lang.NoClassDefFoundError: jenkins/slaves/restarter/JnlpSlaveRestarterInstaller 
              at 
          

          Can be reproduced with a "Permanent" agent by just ctrl+c'ing the controller while the agent is running.
          Reproduced on:

          Remoting 4.12
          Java 11
          Jenkins 2.336

          Only reproduce-able on Websocket protocol.

          Couldn't reproduce on Java 8.

          cc jglick if you're interested

          Tim Jacomb added a comment - The java.lang.NoClassDefFoundError: jenkins/slaves/restarter/JnlpSlaveRestarterInstaller at Can be reproduced with a "Permanent" agent by just ctrl+c'ing the controller while the agent is running. Reproduced on: Remoting 4.12 Java 11 Jenkins 2.336 Only reproduce-able on Websocket protocol. Couldn't reproduce on Java 8. cc jglick if you're interested

          Jesse Glick added a comment -

          JENKINS-19055 introduced JnlpSlaveRestarterInstaller by the way. Despite the name, and SlaveRestarter Javadoc, it does not appear to have ever limited its action to inbound agents (though perhaps only inbound agents would ever send the event that is listens for).

          Jesse Glick added a comment - JENKINS-19055 introduced JnlpSlaveRestarterInstaller by the way. Despite the name, and SlaveRestarter Javadoc, it does not appear to have ever limited its action to inbound agents (though perhaps only inbound agents would ever send the event that is listens for).

          Basil Crow added a comment -

          Fixed in jenkinsci/remoting#514 toward 4.13.

          Basil Crow added a comment - Fixed in jenkinsci/remoting#514 toward 4.13.

          Basil Crow added a comment -

          Basil Crow added a comment - Fixed in jenkinsci/jenkins#6315 and jenkinsci/jenkins#6329 toward 2.338.

          Basil Crow added a comment -

          felipecassiors has requested a backport in jenkinsci/jenkins#6315 (comment) and has verified the fix in jenkinsci/jenkins#6315 (comment). Therefore, I have added the lts-candidate label.

          Basil Crow added a comment - felipecassiors has requested a backport in jenkinsci/jenkins#6315 (comment) and has verified the fix in jenkinsci/jenkins#6315 (comment) . Therefore, I have added the lts-candidate label.

            timja Tim Jacomb
            dordor dor s
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: