Add Verbose Filters to Counting Existing Instances #650
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the case of when there are multiple Jenkins in the same AWS account sharing the same URL but in different VPCs (e.g. when migrating from 1 Kubernetes cluster to another)
Similar (but not exactly) to : #310
When counting the number of existing instances to determine if there's capacity to create new instances for a given SlaveTemplate, there is a bug where the EC2 plugin will count EC2 instances regardless of different characteristics than the ones configured on the given SlaveTemplate: notably security group, subnet, VPC, and IAM roles. Instances with different characteristics than those on the given SlaveTemplate shouldn't be counted as it could have different network permissions, be unreachable due to different subnets, etc.
Fix is to add more verbose filters when making the AWS request for instance count. The following filters were added: security group, subnet, IAM role, VPC.
Note VPC is only added when counting all instances and uses the given SlaveTemplate's configured subnet to get the respective VPC.