From 41ba4a3b3e39c22ef2e6284431f0e008d47fb4e6 Mon Sep 17 00:00:00 2001 From: Chris McCarroll-Gilbert Date: Wed, 1 Feb 2023 13:41:42 -0700 Subject: [PATCH 1/2] describe instances --- .../plugin/resources/ec2/InstanceToNodeMapper.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapper.java b/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapper.java index f0149f69..60d590cf 100644 --- a/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapper.java +++ b/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapper.java @@ -146,6 +146,20 @@ public NodeSetImpl performQuery() { } else if(region != null){ ec2.setEndpoint("https://ec2." + region + ".amazonaws.com"); + zones = ec2.describeAvailabilityZones(); + final ArrayList filters = buildFilters(); + + final Set newInstances = addExtraMappingAttribute(query(ec2, new DescribeInstancesRequest().withFilters(filters).withMaxResults(maxResults))); + + if (!newInstances.isEmpty() && newInstances != null) { + instances.addAll(newInstances); + } + + try { + Thread.sleep(100); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } } else{ zones = ec2.describeAvailabilityZones(); From 62c98b048dfd4748b84cdf82628e6d1e955297a5 Mon Sep 17 00:00:00 2001 From: Chris McCarroll-Gilbert Date: Wed, 1 Feb 2023 13:51:07 -0700 Subject: [PATCH 2/2] address eric's comments --- .../rundeck/plugin/resources/ec2/InstanceToNodeMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapper.java b/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapper.java index 60d590cf..bc62f968 100644 --- a/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapper.java +++ b/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/InstanceToNodeMapper.java @@ -151,7 +151,7 @@ else if(region != null){ final Set newInstances = addExtraMappingAttribute(query(ec2, new DescribeInstancesRequest().withFilters(filters).withMaxResults(maxResults))); - if (!newInstances.isEmpty() && newInstances != null) { + if (newInstances != null && !newInstances.isEmpty()) { instances.addAll(newInstances); }