Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JENKINS-62212 Add filter to periodic EC2 connection polling #456

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/hudson/plugins/ec2/EC2Cloud.java
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,10 @@ protected void doRun() throws IOException {
LOGGER.finer(() -> "Checking EC2 Connection on: " + ec2_cloud.getDisplayName());
try {
if(ec2_cloud.connection != null) {
ec2_cloud.connection.describeInstances();
List<Filter> filters = new ArrayList<>();
filters.add(new Filter("tag-key").withValues("bogus-EC2ConnectionKeepalive"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there's a more idiomatic way to craft a filter that returns few/no instances, while also not triggering an AmazonClientException. This was just the first thing that came to mind.

DescribeInstancesRequest dir = new DescribeInstancesRequest().withFilters(filters);
ec2_cloud.connection.describeInstances(dir);
}
} catch (AmazonClientException e) {
LOGGER.finer(() -> "Reconnecting to EC2 on: " + ec2_cloud.getDisplayName());
Expand Down