Permalink
Browse files

Give Jenkins nodes useful names.

EC2 slave nodes will now include their template name and EC2 instance
identifiers in the node name used throughout the Jenkins UI.

Addresses [JENKINS-15078].
  • Loading branch information...
1 parent f0d1e98 commit 88222567e84ae42c602d5ac8430a95957ea083e3 @kpfleming kpfleming committed Jan 2, 2013
@@ -55,7 +55,8 @@ public EC2Slave getNode() {
}
public String getInstanceId() {
- return getName();
+ EC2Slave node = (EC2Slave) super.getNode();
+ return node.getInstanceId();
}
/**
@@ -61,6 +61,7 @@
* @author Kohsuke Kawaguchi
*/
public final class EC2Slave extends Slave {
+ public final String instanceId;
/**
* Comes from {@link SlaveTemplate#initScript}.
*/
@@ -106,8 +107,9 @@ public EC2Slave(String instanceId, String description, String remoteFS, int sshP
@DataBoundConstructor
public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, Mode mode, String labelString, String initScript, List<? extends NodeProperty<?>> nodeProperties, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, boolean usePrivateDnsName) throws FormException, IOException {
- super(instanceId, description, remoteFS, numExecutors, mode, labelString, new EC2UnixLauncher(), new EC2RetentionStrategy(idleTerminationMinutes), nodeProperties);
+ super(description + " (" + instanceId + ")", "", remoteFS, numExecutors, mode, labelString, new EC2UnixLauncher(), new EC2RetentionStrategy(idleTerminationMinutes), nodeProperties);
+ this.instanceId = instanceId;
this.initScript = initScript;
this.remoteAdmin = remoteAdmin;
this.rootCommandPrefix = rootCommandPrefix;
@@ -153,7 +155,7 @@ public EC2Slave(String instanceId) throws FormException, IOException {
* EC2 instance ID.
*/
public String getInstanceId() {
- return getNodeName();
+ return instanceId;
}
@Override
@@ -225,15 +227,15 @@ boolean terminateInstance() {
}
}
- void idleTimeout() {
- LOGGER.info("EC2 instance idle time expired: "+getInstanceId());
- if (!stopOnTerminate) {
- terminate();
- }
- else {
- stop();
- }
+ void idleTimeout() {
+ LOGGER.info("EC2 instance idle time expired: "+getInstanceId());
+ if (!stopOnTerminate) {
+ terminate();
}
+ else {
+ stop();
+ }
+ }
String getRemoteAdmin() {
if (remoteAdmin == null || remoteAdmin.length() == 0)
@@ -275,7 +277,7 @@ private void fetchLiveInstanceData( boolean force ) throws AmazonClientException
return;
}
- Instance i = getInstance(getNodeName());
+ Instance i = getInstance(getInstanceId());
lastFetchTime = now;
lastFetchInstance = i;
@@ -294,7 +296,7 @@ private void fetchLiveInstanceData( boolean force ) throws AmazonClientException
/* Clears all existing tag data so that we can force the instance into a known state */
private void clearLiveInstancedata() throws AmazonClientException {
- Instance inst = getInstance(getNodeName());
+ Instance inst = getInstance(getInstanceId());
/* Now that we have our instance, we can clear the tags on it */
if (!tags.isEmpty()) {
@@ -313,7 +315,7 @@ private void clearLiveInstancedata() throws AmazonClientException {
/* Sets tags on an instance. This will not clear existing tag data, so call clearLiveInstancedata if needed */
private void pushLiveInstancedata() throws AmazonClientException {
- Instance inst = getInstance(getNodeName());
+ Instance inst = getInstance(getInstanceId());
/* Now that we have our instance, we can set tags on it */
if (tags != null && !tags.isEmpty()) {
@@ -225,7 +225,7 @@ public EC2Slave provision(TaskListener listener) throws AmazonClientException, I
AmazonEC2 ec2 = getParent().connect();
try {
- logger.println("Launching "+ami);
+ logger.println("Launching " + ami + " for template " + description);
KeyPair keyPair = parent.getPrivateKey().find(ec2);
if(keyPair==null) {
throw new AmazonClientException("No matching keypair found on EC2. Is the EC2 private key a valid one?");

0 comments on commit 8822256

Please sign in to comment.