Skip to content

Commit

Permalink
Merge pull request #999 from Dohbedoh/enahncement/sg-troubleshooting
Browse files Browse the repository at this point in the history
Adding FINE logging in SG lookups for easier troubleshooting
  • Loading branch information
res0nance authored Nov 14, 2024
2 parents 048a6fb + cc9dfd3 commit 47818f8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/hudson/plugins/ec2/SlaveTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ HashMap<RunInstancesRequest, List<Filter>> makeRunInstancesRequestAndFilters(Ima
}

String subnetId = chooseSubnetId(rotateSubnet);
LOGGER.log(Level.FINE, () -> String.format("Chose subnetId %s", subnetId));

InstanceNetworkInterfaceSpecification net = new InstanceNetworkInterfaceSpecification();
if (StringUtils.isNotBlank(subnetId)) {
Expand Down Expand Up @@ -1436,6 +1437,7 @@ private List<EC2AbstractSlave> provisionSpot(Image image, int number, EnumSet<Pr

InstanceNetworkInterfaceSpecification net = new InstanceNetworkInterfaceSpecification();
String subnetId = chooseSubnetId();
LOGGER.log(Level.FINE, () -> String.format("Chose subnetId %s", subnetId));
if (StringUtils.isNotBlank(subnetId)) {
net.setSubnetId(subnetId);

Expand Down Expand Up @@ -1692,14 +1694,17 @@ private void updateRemoteTags(AmazonEC2 ec2, Collection<Tag> instTags, String ca
* Get a list of security group ids for the agent
*/
private List<String> getEc2SecurityGroups(AmazonEC2 ec2) throws AmazonClientException {
LOGGER.log(Level.FINE, () -> String.format("Get security group %s for EC2Cloud %s with currentSubnetId %s",
securityGroupSet, this.getParent().name, getCurrentSubnetId()));

Check warning on line 1698 in src/main/java/hudson/plugins/ec2/SlaveTemplate.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 1698 is not covered by tests
List<String> groupIds = new ArrayList<>();

DescribeSecurityGroupsResult groupResult = getSecurityGroupsBy("group-name", securityGroupSet, ec2);
if (groupResult.getSecurityGroups().size() == 0) {
groupResult = getSecurityGroupsBy("group-id", securityGroupSet, ec2);
}

for (SecurityGroup group : groupResult.getSecurityGroups()) {
LOGGER.log(Level.FINE, () -> String.format("Checking security group %s (vpc-id = %s, subnet-id = %s)",
group.getGroupId(), group.getVpcId(), getCurrentSubnetId()));

Check warning on line 1707 in src/main/java/hudson/plugins/ec2/SlaveTemplate.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 1707 is not covered by tests
if (group.getVpcId() != null && !group.getVpcId().isEmpty()) {
List<Filter> filters = new ArrayList<>();
filters.add(new Filter("vpc-id").withValues(group.getVpcId()));
Expand All @@ -1712,6 +1717,7 @@ private List<String> getEc2SecurityGroups(AmazonEC2 ec2) throws AmazonClientExce

List<Subnet> subnets = subnetResult.getSubnets();
if (subnets != null && !subnets.isEmpty()) {
LOGGER.log(Level.FINE, () -> "Adding security group");
groupIds.add(group.getGroupId());
}
}
Expand Down

0 comments on commit 47818f8

Please sign in to comment.