Skip to content
Browse files

Provide backwards compatibility for EC2Slave name change.

Commit 8822256 changed the way that
Node objects are constructed from EC2Slave objects, in order to make the
Node 'name' fields more useful. It also added a field called 'instanceId'
to EC2Slave, and stopped relying on Node.getNodeName() to recover that
information. In order to provide compatibility with configurations from
before this change was made, this patch notes whether instanceId is null,
and if it is, extracts the instance ID from the Node's name.
  • Loading branch information...
1 parent 7a64483 commit 44a9f2953735ce49d98187240505a238f1f01ae4 @kpfleming kpfleming committed Mar 5, 2013
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/main/java/hudson/plugins/ec2/EC2Slave.java
View
16 src/main/java/hudson/plugins/ec2/EC2Slave.java
@@ -61,7 +61,7 @@
* @author Kohsuke Kawaguchi
*/
public final class EC2Slave extends Slave {
- public final String instanceId;
+ public String instanceId;
/**
* Comes from {@link SlaveTemplate#initScript}.
*/
@@ -123,6 +123,20 @@ public EC2Slave(String instanceId, String description, String remoteFS, int sshP
this.usePrivateDnsName = usePrivateDnsName;
}
+ protected Object readResolve() {
+ /*
+ * If instanceId is null, this object was deserialized from an old
+ * version of the plugin, where this field did not exist. In those
+ * versions, the node name *was* the instance ID, so we can get it
+ * from there.
+ */
+ if (instanceId == null) {
+ instanceId = getNodeName();
+ }
+
+ return this;
+ }
+
/**
* Constructor for debugging.
*/

0 comments on commit 44a9f29

Please sign in to comment.
Something went wrong with that request. Please try again.