Skip to content

Commit

Permalink
fix(lb): ACL with /32 subnets were not matching properly (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nox-404 committed Feb 6, 2024
1 parent cea0d51 commit 43358c4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scaleway/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ func makeACLSpecs(service *v1.Service, nodes []*v1.Node, frontend *scwlb.Fronten
aclPrefix := makeACLPrefix(frontend)
whitelist := extractNodesInternalIps(nodes)
whitelist = append(whitelist, extractNodesExternalIps(nodes)...)
whitelist = append(whitelist, service.Spec.LoadBalancerSourceRanges...)
whitelist = append(whitelist, strip32SubnetMasks(service.Spec.LoadBalancerSourceRanges)...)

slices.Sort(whitelist)

Expand Down Expand Up @@ -2277,6 +2277,14 @@ func makeACLSpecs(service *v1.Service, nodes []*v1.Node, frontend *scwlb.Fronten
return acls
}

func strip32SubnetMasks(subnets []string) []string {
stripped := make([]string, len(subnets))
for idx, subnet := range subnets {
stripped[idx] = strings.TrimSuffix(subnet, "/32")
}
return stripped
}

func ptrInt32ToString(i *int32) string {
if i == nil {
return "<nil>"
Expand Down

0 comments on commit 43358c4

Please sign in to comment.