egib
egib

Reputation: 31

Jenkins Agent EC2 instance creation fails with a 404 NOT FOUND error

I've been running a sole Agent Master EC2 instance where we ran all of our jobs. I'm looking into upgrading our solution and add some Jenkins Agents depending on the load. To do that I'm trying to use the EC2 Plugin provided in Jenkins.The configuration is going fine, just so I can test this I'm setting Minimum number of instances as '1'. Jenkins Master can SSH to the Agent once the agent has been initizalied but once it SSH it returns an 404 ERROR and the instance is terminated, which I don't know why is it happening. This is the error :

Nov 09, 2020 12:15:58 PM hudson.plugins.ec2.EC2Cloud
INFO: The SSH key **** has been successfully checked against the instance console for connections to EC2 (Jenkins Agent 1) - Jenkins Agent (****)
Nov 09, 2020 12:15:58 PM hudson.plugins.ec2.EC2Cloud
INFO: Connected via SSH.
Nov 09, 2020 12:15:58 PM hudson.plugins.ec2.EC2Cloud
INFO: connect fresh as root
Nov 09, 2020 12:15:58 PM hudson.plugins.ec2.EC2Cloud
INFO: Connecting to **** on port ****, with timeout 10000.
Nov 09, 2020 12:15:58 PM hudson.plugins.ec2.EC2Cloud
INFO: Connection allowed after the host key has been verified
Nov 09, 2020 12:15:58 PM hudson.plugins.ec2.EC2Cloud
INFO: Connected via SSH.
Nov 09, 2020 12:15:58 PM hudson.plugins.ec2.EC2Cloud
INFO: Creating tmp directory (/tmp) if it does not exist
Nov 09, 2020 12:16:03 PM hudson.plugins.ec2.EC2Cloud
INFO: Verifying: java -fullversion
openjdk full version "1.8.0_265-8u265-b01-0ubuntu2~20.04-b01"
Nov 09, 2020 12:16:03 PM hudson.plugins.ec2.EC2Cloud
INFO: Verifying: which scp
/usr/bin/scp
Nov 09, 2020 12:16:03 PM hudson.plugins.ec2.EC2Cloud
INFO: Copying remoting.jar to: /tmp
Nov 09, 2020 12:16:03 PM hudson.plugins.ec2.EC2Cloud
INFO: Launching remoting agent (via Trilead SSH2 Connection):  java  -jar /tmp/remoting.jar -workDir /var/lib/jenkins





HTTP ERROR 404 Not Found

URI:    /computer/EC2%20(Jenkins%20Agent%201)%20-%20Jenkins%20Agent%20(i-01c45e1be3ca4ab2f)/logText/progressiveHtml
STATUS: 404
MESSAGE:    Not Found
SERVLET:    Stapler

Powered by Jetty:// 9.4.30.v20200611

Anyone knows where is this coming from, or had this before with the EC2 Plugin on Jenkins?

Upvotes: 1

Views: 2470

Answers (3)

Thilina Viraj
Thilina Viraj

Reputation: 131

Issue with the command it executed. java -jar /tmp/remoting.jar -workDir /var/lib/jenkins There's an additional space after java. Once you remove it it should work.

Upvotes: 0

RaghuCK
RaghuCK

Reputation: 125

This error comes when you are trying to use AmazonLinux2 AMI which doesn't have java installed by default. The java is needed to run the agent jar (remoting.jar) to establish connection with Jenkins Master.

Solution: Add java installation command (sudo yum install java -y) in the init section of the "Configure Clouds"

Upvotes: 0

Romar C.
Romar C.

Reputation: 51

INFO: Verifying: which scp
/usr/bin/scp
Nov 09, 2020 12:16:03 PM hudson.plugins.ec2.EC2Cloud
INFO: Copying remoting.jar to: /tmp
Nov 09, 2020 12:16:03 PM hudson.plugins.ec2.EC2Cloud
INFO: Launching remoting agent (via Trilead SSH2 Connection):  java  -jar 
/tmp/remoting.jar -workDir /var/lib/jenkins

It seems that the scp lib/package is already installed/available but the remote-user you are using has no permission to the working directory /var/lib/jenkins that's why it fails and the instance gets terminated. If you are using Amazon Linux 2 AMI you may opt to use /home/ec2-user as the Remote FS root see image reference or /home/ubuntu if you are using Ubuntu AMI

Upvotes: 5

Related Questions