Search code examples
jenkinsjenkins-agent

Unable to connect to Jenkins Agent after upgrade


Upgraded Jenkins from 2.257 to 2.339. After the upgrade none of the nodes are able to connect to the master. Jenkins is hosted on Amazon Linux. This is error I am getting when I try to connect a node to the controller:

Logs from Windows Agent :

SSHLauncher{host='172.*.*.*', port=22, credentialsId='3f7dbc2d-7850-4506-a356-24328ded5b43', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=210, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.ManuallyTrustedKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[03/20/22 14:38:59] [SSH] Opening SSH connection to 172.*.*.*.
[03/20/22 14:38:59] [SSH] SSH host key matches key seen previously for this host. Connection will be allowed.
[03/20/22 14:38:59] [SSH] Authentication successful.
[03/20/22 14:38:59] [SSH] The remote user's environment is:
ALLUSERSPROFILE='C:\<some folder>'
ANDROID_HOME='C:\<some path>'
ANDROID_NDK_HOME='C:\<some path>'
APPDATA='C:\Users\<jenkis user>\AppData\Roaming'
BASH=/bin/bash
BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_EXECUTION_STRING=set
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="4" [2]="12" [3]="3" [4]="release" [5]="x86_64-unknown-cygwin")
BASH_VERSION='4.4.12(3)-release'
COMPUTERNAME=EC2AMAZ-ML17J1C
COMSPEC='C:\Windows\system32\cmd.exe'
CYGWIN=sshd
CYG_SYS_BASHRC=1
CommonProgramFiles='C:\Program Files\Common Files'
CommonProgramW6432='C:\Program Files\Common Files'
DIRSTACK=()
EUID=197608
GROUPS=()
GTK_BASEPATH='C:\Program Files (x86)\GtkSharp\2.12\'
HOME=/home/<some path>
HOMEDRIVE=C:
HOMEPATH='\cygwin64\home\<some path>'
HOSTNAME=someserver
HOSTTYPE=x86_64
IFS=$' \t\n'
JAVA_HOME='C:\Program Files\Java\jdk1.8.0_144'
LOCALAPPDATA='C:\Users\<somem user>\AppData\Local'
LOGNAME=<login user>
LOGONSERVER='\\someserver
M2_HOME='C:\apache-maven-3.3.9'
MACHTYPE=x86_64-unknown-cygwin
MAIL=/var/spool/mail//Jenkins
MAVEN_HOME='C:\apache-maven-3.3.9'
NUMBER_OF_PROCESSORS=4
OPTERR=1
OPTIND=1
OS=Windows_NT
OSTYPE=cygwin
PATH=''
PATHEXT='.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
PIPESTATUS=([0]="0")
PPID=5896
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER='Intel64 Family 6 Model 85 Stepping 7, GenuineIntel'
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=5507
PROGRAMFILES='C:\Program Files'
PS4='+ '
PSModulePath='%ProgramFiles%\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell\'
PUBLIC='C:\Users\Public'
PWD=/home/<somepath>
ProgramData='C:\ProgramData'
ProgramW6432='C:\Program Files'
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=1
SSH_AUTH_SOCK=/tmp/ssh-xQ6x4PUqHRF7/agent.34688
SSH_CLIENT='172.*.*.* 52306 22'
SSH_CONNECTION='172.*.*.* 52306 172.*.*.* 22'
SYSTEMDRIVE=C:
SYSTEMROOT='C:\Windows'
TERM=dumb
UID=197608
USER=<some user>
USERDOMAIN=someserver
USERNAME=<some user>
USERPROFILE='C:\Users\<some user>'
VS140COMNTOOLS='C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\'
WINDIR='C:\Windows'
_=
[03/20/22 14:38:59] [SSH] Checking java version of c:\<some path>/jdk/bin/java
Couldn't figure out the Java version of c:\<some path>/jdk/bin/java
bash: c:<some path>/jdk/bin/java: No such file or directory

[03/20/22 14:38:59] [SSH] Checking java version of java
[03/20/22 14:38:59] [SSH] java -version returned 1.8.0_191.
[03/20/22 14:38:59] [SSH] Starting sftp client.
[03/20/22 14:39:00] [SSH] Copying latest remoting.jar...
java.io.IOException: Could not copy remoting.jar into 'c:\<some path>' on agent
    at hudson.plugins.sshslaves.SSHLauncher.copyAgentJar(SSHLauncher.java:702)
    at hudson.plugins.sshslaves.SSHLauncher.access$300(SSHLauncher.java:113)
    at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:445)
    at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:412)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: invalid len argument
    at com.trilead.ssh2.SFTPv3Client.read(SFTPv3Client.java:1232)
    at com.trilead.ssh2.jenkins.SFTPClient$SFTPInputStream.read(SFTPClient.java:172)
    at com.google.common.io.ByteStreams.toByteArrayInternal(ByteStreams.java:191)
    at com.google.common.io.ByteStreams.toByteArray(ByteStreams.java:238)
    at hudson.plugins.sshslaves.SSHLauncher.readInputStreamIntoByteArrayAndClose(SSHLauncher.java:760)
    at hudson.plugins.sshslaves.SSHLauncher.copyAgentJar(SSHLauncher.java:671)
    ... 7 more
[03/20/22 14:39:00] Launch failed - cleaning up connection
[03/20/22 14:39:00] [SSH] Connection closed.
REST API
Jenkins 2.339

I have 3 different nodes (Windows, Ubuntu and mac). I get the same error on all three:

Caused by: java.lang.IllegalArgumentException: invalid len argument

Appreciate any info to resolve this. Thanks


Solution

  • There is an open issue about your problem: https://issues.jenkins.io/browse/JENKINS-67258.

    According to one of the participant of this issue, a solution is to:

    [...] upgrading SSH Build Agents / SSH Slaves Plugin to version 1.32.0 and beyond [...]