-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use AbstractCloudSlave and AbstractCloudComputer #1015
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,11 @@ | |
import com.amazonaws.services.ec2.AmazonEC2; | ||
import com.amazonaws.services.ec2.model.*; | ||
import hudson.Extension; | ||
import hudson.Functions; | ||
import hudson.model.Computer; | ||
import hudson.model.Descriptor.FormException; | ||
import hudson.model.Node; | ||
import hudson.model.TaskListener; | ||
import hudson.plugins.ec2.ssh.EC2MacLauncher; | ||
import hudson.plugins.ec2.ssh.EC2UnixLauncher; | ||
import hudson.plugins.ec2.win.EC2WindowsLauncher; | ||
|
@@ -435,7 +437,7 @@ public EC2OndemandSlave(String instanceId) throws FormException, IOException { | |
* Terminates the instance in EC2. | ||
*/ | ||
@Override | ||
public void terminate() { | ||
protected void _terminate(TaskListener listener) throws IOException, InterruptedException { | ||
if (terminateScheduled.getCount() == 0) { | ||
synchronized (terminateScheduled) { | ||
if (terminateScheduled.getCount() == 0) { | ||
|
@@ -456,7 +458,8 @@ public void terminate() { | |
Jenkins.get().removeNode(this); | ||
LOGGER.info("Removed EC2 instance from jenkins controller: " + getInstanceId()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of these |
||
} catch (AmazonClientException | IOException e) { | ||
LOGGER.log(Level.WARNING, "Failed to terminate EC2 instance: " + getInstanceId(), e); | ||
Functions.printStackTrace( | ||
e, listener.error("Failed to terminate EC2 instance: " + getInstanceId())); | ||
} finally { | ||
synchronized (terminateScheduled) { | ||
terminateScheduled.countDown(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ | |
import com.amazonaws.services.ec2.model.TerminateInstancesRequest; | ||
import edu.umd.cs.findbugs.annotations.CheckForNull; | ||
import hudson.Extension; | ||
import hudson.Functions; | ||
import hudson.model.Computer; | ||
import hudson.model.Descriptor.FormException; | ||
import hudson.model.TaskListener; | ||
import hudson.plugins.ec2.ssh.EC2UnixLauncher; | ||
import hudson.plugins.ec2.win.EC2WindowsLauncher; | ||
import hudson.slaves.NodeProperty; | ||
|
@@ -178,7 +180,7 @@ protected boolean isAlive(boolean force) { | |
* Cancel the spot request for the instance. Terminate the instance if it is up. Remove the agent from Jenkins. | ||
*/ | ||
@Override | ||
public void terminate() { | ||
protected void _terminate(TaskListener listener) throws IOException, InterruptedException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The impl seems mostly the same as in |
||
if (terminateScheduled.getCount() == 0) { | ||
synchronized (terminateScheduled) { | ||
if (terminateScheduled.getCount() == 0) { | ||
|
@@ -196,7 +198,8 @@ public void terminate() { | |
LOGGER.info("Cancelled Spot request: " + spotInstanceRequestId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto here |
||
} catch (AmazonClientException e) { | ||
// Spot request is no longer valid | ||
LOGGER.log(Level.WARNING, "Failed to cancel Spot request: " + spotInstanceRequestId, e); | ||
Functions.printStackTrace( | ||
e, listener.error("Failed to cancel Spot request: " + spotInstanceRequestId)); | ||
} | ||
|
||
// Terminate the agent if it is running | ||
|
@@ -214,15 +217,14 @@ public void terminate() { | |
LOGGER.info("Terminated EC2 instance (terminated): " + instanceId); | ||
} catch (AmazonClientException e) { | ||
// Spot request is no longer valid | ||
LOGGER.log( | ||
Level.WARNING, | ||
"Failed to terminate the Spot instance: " + instanceId, | ||
e); | ||
Functions.printStackTrace( | ||
e, | ||
listener.error("Failed to terminate the Spot instance: " + instanceId)); | ||
} | ||
} | ||
} | ||
} catch (Exception e) { | ||
LOGGER.log(Level.WARNING, "Failed to remove agent: ", e); | ||
Functions.printStackTrace(e, listener.error("Failed to remove agent")); | ||
} finally { | ||
// Remove the instance even if deletion failed, otherwise it will hang around forever in | ||
// the nodes page. One way for this to occur is that an instance was terminated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pay attention to https://github.com/jenkinsci/jenkins/blob/4248fc0ca6ce108364ed23208063ff20753f5e70/core/src/main/java/hudson/slaves/AbstractCloudSlave.java#L88-L94 which means that after switching from |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto here