Skip to content

Commit

Permalink
Pass tag value as fleet name
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Stasiuk committed Oct 9, 2019
1 parent ebad52f commit 2fe29e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/amazon/jenkins/ec2fleet/EC2FleetCloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
@SuppressWarnings({"unused", "WeakerAccess"})
public class EC2FleetCloud extends Cloud {

public static final String EC2_INSTANCE_TAG = "ec2-fleet-plugin";
public static final String EC2_INSTANCE_TAG_NAMESPACE = "ec2-fleet-plugin";
public static final String EC2_INSTANCE_CLOUD_NAME_TAG = EC2_INSTANCE_TAG_NAMESPACE + ":cloud-name";

public static final String FLEET_CLOUD_ID = "FleetCloud";

Expand Down Expand Up @@ -509,7 +510,8 @@ public void run() {
// we tag new instances to help users to identify instances launched from plugin managed fleets
// if failed we are fine to skip this call
try {
Registry.getEc2Api().tagInstances(ec2, newFleetInstances.keySet(), EC2_INSTANCE_TAG, name);
Registry.getEc2Api().tagInstances(ec2, newFleetInstances.keySet(),
EC2_INSTANCE_CLOUD_NAME_TAG, name);
} catch (final Exception e) {
warning("failed to tag new instances %s, skip", newFleetInstances.keySet());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ public void update_shouldTagNewNodesBeforeAdding() throws IOException {
fleetCloud.update();

// then
verify(ec2Api).tagInstances(amazonEC2, ImmutableSet.of("i-0", "i-1"), "ec2-fleet-plugin", "FleetCloud");
verify(ec2Api).tagInstances(amazonEC2, ImmutableSet.of("i-0", "i-1"), "ec2-fleet-plugin:cloud-name", "FleetCloud");
Node actualFleetNode = nodeCaptor.getValue();
assertEquals(Node.Mode.NORMAL, actualFleetNode.getMode());
}
Expand Down Expand Up @@ -729,7 +729,7 @@ public void update_shouldTagNewNodesBeforeAddingWithFleetName() throws IOExcepti
fleetCloud.update();

// then
verify(ec2Api).tagInstances(amazonEC2, ImmutableSet.of("i-0"), "ec2-fleet-plugin", "my-fleet");
verify(ec2Api).tagInstances(amazonEC2, ImmutableSet.of("i-0"), "ec2-fleet-plugin:cloud-name", "my-fleet");
Node actualFleetNode = nodeCaptor.getValue();
assertEquals(Node.Mode.NORMAL, actualFleetNode.getMode());
}
Expand Down Expand Up @@ -767,7 +767,7 @@ public void update_givenFailedTaggingShouldIgnoreExceptionAndAddNode() throws IO
fleetCloud.update();

// then
verify(ec2Api).tagInstances(amazonEC2, ImmutableSet.of("i-0"), "ec2-fleet-plugin", "FleetCloud");
verify(ec2Api).tagInstances(amazonEC2, ImmutableSet.of("i-0"), "ec2-fleet-plugin:cloud-name", "FleetCloud");
Node actualFleetNode = nodeCaptor.getValue();
assertEquals(Node.Mode.NORMAL, actualFleetNode.getMode());
}
Expand Down

0 comments on commit 2fe29e6

Please sign in to comment.