diff --git a/Readme.md b/Readme.md index 1254e9c6..a0902d33 100644 --- a/Readme.md +++ b/Readme.md @@ -35,7 +35,8 @@ Here are the configuration properties: * `accessKey`: API AccessKey value (if not using IAM profile) * `secretKey`: API SecretKey value (if not using IAM profile) * `endpoint` - the URL of the AWS **endpoint** to use, or blank for the default endpoint (see [Amazon EC2 Regions and Endpoints](http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region)) -* `refreshInterval`: Time in seconds used as minimum interval between calls to the AWS API. (default 30) +* `synchronousLoad`: Do not use internal async loading behavior. (boolean, default: true) +* `refreshInterval`: Unless using Synchronous Loading, time in seconds used as minimum interval between calls to the AWS API. (default 30) * `filter` A set of ";" separated query filters ("$Name=$Value") for the AWS EC2 API, see below. * `runningOnly`: if "true", automatically filter the * instances by "instance-state-name=running" * `useDefaultMapping`: if "true", base all mapping definitions off the default mapping provided. @@ -44,6 +45,10 @@ Here are the configuration properties: If you leave `accessKey` and `secretKey` blank, the EC2 IAM profile will be used. +Note: Rundeck 2.6.3+ uses an asynchronous nodes cache by +default. You should enable `synchronousLoad` if you are using the +rundeck nodes cache, or set the `refreshInterval` to 0. + ## Filter definition The syntax for defining filters uses `$Name=$Value[;$Name=$value[;...]]` for any of the allowed filter names (see [DescribeInstances][1] for the available filter Names). *Note*: you do not need to specify `Filter.1.Name=$Name`, etc. as described in the EC2 API documentation, this will handled for you. Simply list the Name = Value pairs, separated by `;`. diff --git a/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSource.java b/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSource.java index 67fe6c5f..af914e2e 100644 --- a/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSource.java +++ b/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSource.java @@ -40,6 +40,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import static com.dtolabs.rundeck.plugin.resources.ec2.EC2ResourceModelSourceFactory.SYNCHRONOUS_LOAD; + /** * EC2ResourceModelSource produces nodes by querying the AWS EC2 API to list instances. *

@@ -186,6 +188,7 @@ public EC2ResourceModelSource(final Properties configuration) { clientConfiguration.setProxyUsername(httpProxyUser); clientConfiguration.setProxyPassword(httpProxyPass); } + queryAsync = !("true".equals(configuration.getProperty(SYNCHRONOUS_LOAD)) || refreshInterval <= 0); initialize(); } diff --git a/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSourceFactory.java b/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSourceFactory.java index 7eb7de00..8a7d9c5b 100644 --- a/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSourceFactory.java +++ b/src/main/java/com/dtolabs/rundeck/plugin/resources/ec2/EC2ResourceModelSourceFactory.java @@ -62,6 +62,7 @@ public class EC2ResourceModelSourceFactory implements ResourceModelSourceFactory public static final String ROLE_ARN = "assumeRoleArn"; public static final String MAPPING_FILE = "mappingFile"; public static final String REFRESH_INTERVAL = "refreshInterval"; + public static final String SYNCHRONOUS_LOAD = "synchronousLoad"; public static final String USE_DEFAULT_MAPPING = "useDefaultMapping"; public static final String HTTP_PROXY_HOST = "httpProxyHost"; public static final String HTTP_PROXY_PORT = "httpProxyPort"; @@ -107,8 +108,18 @@ public ResourceModelSource createResourceModelSource(final Properties properties null ) ) - .property(PropertyUtil.integer(REFRESH_INTERVAL, "Refresh Interval", - "Minimum time in seconds between API requests to AWS (default is 30)", false, "30")) + .property(PropertyUtil.bool( + SYNCHRONOUS_LOAD, + "Synchronous Loading", + "Do not use internal async loading behavior.\n\n" + + "Note: Rundeck 2.6.3+ uses an asynchronous nodes cache by " + + "default. You should enable this if you are using the " + + "rundeck nodes cache.", + false, + "true" + )) + .property(PropertyUtil.integer(REFRESH_INTERVAL, "Async Refresh Interval", + "Unless using Synchronous Loading, minimum time in seconds between API requests to AWS (default is 30)", false, "30")) .property(PropertyUtil.string(FILTER_PARAMS, "Filter Params", "AWS EC2 filters", false, null)) .property(PropertyUtil.string(ENDPOINT, "Endpoint", "AWS EC2 Endpoint, or blank for default", false, null)) .property(PropertyUtil.string(HTTP_PROXY_HOST, "HTTP Proxy Host", "HTTP Proxy Host Name, or blank for default", false, null))