From e72cd71ccd783d539b206b0e87114c7cfc6d2e48 Mon Sep 17 00:00:00 2001 From: Bushra Manga Date: Tue, 19 Mar 2024 16:14:02 +0800 Subject: [PATCH 1/2] Terminate the EC2 on receiving an exception --- src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java b/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java index 663a356d6..74d1f10e0 100644 --- a/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java +++ b/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java @@ -210,9 +210,9 @@ protected void launchScript(EC2Computer computer, TaskListener listener) throws int exitStatus = waitCompletion(sess); if (exitStatus != 0) { logWarning(computer, listener, "init script failed: exit code=" + exitStatus); - return; + sess.close(); + throw new IOException("Init script exited with an error"); } - sess.close(); logInfo(computer, listener, "Creating ~/.hudson-run-init"); From 4141e6b3a91059799976d1d90b26aaa3c1676722 Mon Sep 17 00:00:00 2001 From: Bushra Manga Date: Wed, 20 Mar 2024 13:15:16 +0800 Subject: [PATCH 2/2] Printing exit status while throwing exception --- src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java b/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java index 74d1f10e0..cad5b68ef 100644 --- a/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java +++ b/src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java @@ -211,7 +211,7 @@ protected void launchScript(EC2Computer computer, TaskListener listener) throws if (exitStatus != 0) { logWarning(computer, listener, "init script failed: exit code=" + exitStatus); sess.close(); - throw new IOException("Init script exited with an error"); + throw new IOException("Init script exited with an error: exit code=" + exitStatus); } logInfo(computer, listener, "Creating ~/.hudson-run-init");