Skip to content

Commit

Permalink
fix(provider/aws): Return load balancers for all target groups associ…
Browse files Browse the repository at this point in the history
…ated with an application (#1955)
  • Loading branch information
Justin Reynolds authored Oct 4, 2017
1 parent 692564e commit a1bd15b
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,25 @@ class AmazonLoadBalancerProvider implements LoadBalancerProvider<AmazonLoadBalan
}
}

// Add load balancers that were created as a part of this application
Collection<String> loadBalancerKeyMatches = allLoadBalancerKeys.findAll { applicationMatcher(it, applicationName) }
loadBalancerKeys.addAll(loadBalancerKeyMatches)

// Add target groups that were created as a part of this application
Collection<String> targetGroupKeyMatches = allTargetGroupKeys.findAll { applicationMatcher(it, applicationName) }
targetGroupKeys.addAll(targetGroupKeyMatches)

// Add load balancer keys for all target groups that are associated with the application
Collection<CacheData> tgd = cacheView.getAll(TARGET_GROUPS.ns, targetGroupKeys)
tgd.each { targetGroup ->
Collection<String> targetGroupLoadBalancers = targetGroup.relationships[LOAD_BALANCERS.ns] ?: []
targetGroupLoadBalancers.each {
loadBalancerKeys.add(it)
String vpcKey = it + ':vpc-'
targetGroupKeys.addAll(allTargetGroupKeys.findAll { it.startsWith(vpcKey) })
}
}

// Get all load balancers
Collection<CacheData> loadBalancerData = cacheView.getAll(LOAD_BALANCERS.ns, loadBalancerKeys)
Collection<CacheData> allLoadBalancerServerGroups = resolveRelationshipDataForCollection(loadBalancerData, SERVER_GROUPS.ns)
Expand Down

0 comments on commit a1bd15b

Please sign in to comment.