Skip to content

Commit 156efdb

Browse files
authored
Merge pull request #1235 from cbajumpaa/check-subnet-free-ips
Check for sufficient available free IP space before marking a subnet as useable
2 parents 94dbcaf + d74ddba commit 156efdb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/alb/lb/loadbalancer.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func (controller *defaultController) clusterSubnets(ctx context.Context, scheme
384384
}
385385

386386
if len(out) < 2 {
387-
return nil, fmt.Errorf(`failed to resolve 2 qualified subnet for ALB. Subnets must contains these tags: '%s/%s': ['shared' or 'owned'] and '%s': ['' or '1']. See https://kubernetes-sigs.github.io/aws-alb-ingress-controller/guide/controller/config/#subnet-auto-discovery for more details. Resolved qualified subnets: '%s'`,
387+
return nil, fmt.Errorf(`failed to resolve 2 qualified subnet with at least 8 free IP Addresses for ALB. Subnets must contains these tags: '%s/%s': ['shared' or 'owned'] and '%s': ['' or '1']. See https://kubernetes-sigs.github.io/aws-alb-ingress-controller/guide/controller/config/#subnet-auto-discovery for more details. Resolved qualified subnets: '%s'`,
388388
aws.TagNameCluster, controller.cloud.GetClusterName(), key, log.Prettify(out))
389389
}
390390

@@ -395,11 +395,17 @@ func (controller *defaultController) clusterSubnets(ctx context.Context, scheme
395395
// subnetIsUsable determines if the subnet shares the same availability zone as a subnet in the
396396
// existing list. If it does, false is returned as you cannot have albs provisioned to 2 subnets in
397397
// the same availability zone.
398+
// Also determine if the subnet has sufficient free IP space available.
398399
func subnetIsUsable(new *ec2.Subnet, existing []*ec2.Subnet) bool {
399400
for _, subnet := range existing {
400401
if *new.AvailabilityZone == *subnet.AvailabilityZone {
401402
return false
402403
}
403404
}
405+
406+
if aws.Int64Value(new.AvailableIpAddressCount) < 8 {
407+
return false
408+
}
409+
404410
return true
405411
}

0 commit comments

Comments
 (0)