Skip to content

Commit

Permalink
Merge pull request kubernetes#437 from sjenning/skip-subset-health-rules
Browse files Browse the repository at this point in the history
Skip health rule creation when it is a subset of the client rule
  • Loading branch information
k8s-ci-robot authored Aug 30, 2022
2 parents c72f89b + eb550e0 commit 391ab7d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/providers/v1/aws_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,12 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLB(lbName string, instances map[
for sgID, sg := range clusterSGs {
sgPerms := NewIPPermissionSet(sg.IpPermissions...).Ungroup()
if desiredSGIDs.Has(sgID) {
if err := c.updateInstanceSecurityGroupForNLBTraffic(sgID, sgPerms, healthRuleAnnotation, "tcp", healthCheckPorts, subnetCIDRs); err != nil {
return err
// If the client rule is 1) all addresses 2) tcp and 3) has same ports as the healthcheck,
// then the health rules are a subset of the client rule and are not needed.
if len(clientCIDRs) != 1 || clientCIDRs[0] != "0.0.0.0/0" || clientProtocol != "tcp" || !healthCheckPorts.Equal(clientPorts) {
if err := c.updateInstanceSecurityGroupForNLBTraffic(sgID, sgPerms, healthRuleAnnotation, "tcp", healthCheckPorts, subnetCIDRs); err != nil {
return err
}
}
if err := c.updateInstanceSecurityGroupForNLBTraffic(sgID, sgPerms, clientRuleAnnotation, clientProtocol, clientPorts, clientCIDRs); err != nil {
return err
Expand Down

0 comments on commit 391ab7d

Please sign in to comment.