Skip to content

Commit

Permalink
Merge pull request #73870 from M00nF1sh/automated-cherry-pick-of-#737…
Browse files Browse the repository at this point in the history
…70-upstream-release-1.11

Automated cherry pick of #73770: support multiple cidr vpc for nlb health check
  • Loading branch information
k8s-ci-robot committed Feb 19, 2019
2 parents a3cd3fe + f9391fc commit 825fb03
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/cloudprovider/providers/aws/aws_loadbalancer.go
Expand Up @@ -582,7 +582,7 @@ func filterForIPRangeDescription(securityGroups []*ec2.SecurityGroup, lbName str
return response
}

func (c *Cloud) getVpcCidrBlock() (*string, error) {
func (c *Cloud) getVpcCidrBlocks() ([]string, error) {
vpcs, err := c.ec2.DescribeVpcs(&ec2.DescribeVpcsInput{
VpcIds: []*string{aws.String(c.vpcID)},
})
Expand All @@ -592,7 +592,12 @@ func (c *Cloud) getVpcCidrBlock() (*string, error) {
if len(vpcs.Vpcs) != 1 {
return nil, fmt.Errorf("Error querying VPC for ELB, got %d vpcs for %s", len(vpcs.Vpcs), c.vpcID)
}
return vpcs.Vpcs[0].CidrBlock, nil

cidrBlocks := make([]string, 0, len(vpcs.Vpcs[0].CidrBlockAssociationSet))
for _, cidr := range vpcs.Vpcs[0].CidrBlockAssociationSet {
cidrBlocks = append(cidrBlocks, aws.StringValue(cidr.CidrBlock))
}
return cidrBlocks, nil
}

// abstraction for updating SG rules
Expand Down Expand Up @@ -805,7 +810,7 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLB(mappings []nlbPortMapping, in
return nil
}

vpcCidr, err := c.getVpcCidrBlock()
vpcCidrBlocks, err := c.getVpcCidrBlocks()
if err != nil {
return err
}
Expand Down Expand Up @@ -890,7 +895,7 @@ func (c *Cloud) updateInstanceSecurityGroupsForNLB(mappings []nlbPortMapping, in
}

// Run once for health check traffic
err = c.updateInstanceSecurityGroupsForNLBTraffic(actualGroups, desiredGroupIds, healthCheckPorts, lbName, []string{aws.StringValue(vpcCidr)}, false)
err = c.updateInstanceSecurityGroupsForNLBTraffic(actualGroups, desiredGroupIds, healthCheckPorts, lbName, vpcCidrBlocks, false)
if err != nil {
return err
}
Expand Down

0 comments on commit 825fb03

Please sign in to comment.