Skip to content

Commit 05fd01b

Browse files
Merge pull request #1358 from sjenning/aws-skip-health-rules-master
OCPBUGS-718: UPSTREAM: 112267: aws: skip health rules if they are a subnet of the client rule
2 parents 07c9eb7 + 6125687 commit 05fd01b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

staging/src/k8s.io/legacy-cloud-providers/aws/aws_loadbalancer.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ import (
3434
"github.com/aws/aws-sdk-go/service/ec2"
3535
"github.com/aws/aws-sdk-go/service/elb"
3636
"github.com/aws/aws-sdk-go/service/elbv2"
37+
v1 "k8s.io/api/core/v1"
3738
"k8s.io/klog/v2"
3839

39-
"k8s.io/api/core/v1"
4040
"k8s.io/apimachinery/pkg/types"
4141
"k8s.io/apimachinery/pkg/util/sets"
4242
)
@@ -840,8 +840,12 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLB(lbName string, instances map[
840840
for sgID, sg := range clusterSGs {
841841
sgPerms := NewIPPermissionSet(sg.IpPermissions...).Ungroup()
842842
if desiredSGIDs.Has(sgID) {
843-
if err := c.updateInstanceSecurityGroupForNLBTraffic(sgID, sgPerms, healthRuleAnnotation, "tcp", healthCheckPorts, subnetCIDRs); err != nil {
844-
return err
843+
// If the client rule is 1) all addresses 2) tcp and 3) has same ports as the healthcheck,
844+
// then the health rules are a subset of the client rule and are not needed.
845+
if len(clientCIDRs) != 1 || clientCIDRs[0] != "0.0.0.0/0" || clientProtocol != "tcp" || !healthCheckPorts.Equal(clientPorts) {
846+
if err := c.updateInstanceSecurityGroupForNLBTraffic(sgID, sgPerms, healthRuleAnnotation, "tcp", healthCheckPorts, subnetCIDRs); err != nil {
847+
return err
848+
}
845849
}
846850
if err := c.updateInstanceSecurityGroupForNLBTraffic(sgID, sgPerms, clientRuleAnnotation, clientProtocol, clientPorts, clientCIDRs); err != nil {
847851
return err

0 commit comments

Comments
 (0)