Skip to content

Commit 787b4a8

Browse files
authored
Merge pull request #2371 from Nordix/lentzi90/release-0.10-lb-subnet-fix
[release-0.10] 🐛 fix: create lbaas in specified subnet
2 parents d4bfe7b + 1f1136f commit 787b4a8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

controllers/openstackcluster_controller.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,19 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
666666

667667
// Filter out only relevant subnets specified by the spec
668668
lbNetStatus.Subnets = []infrav1.Subnet{}
669-
for _, s := range lbSpec.Subnets {
669+
for i := range lbSpec.Subnets {
670+
s := lbSpec.Subnets[i]
670671
matchFound := false
671672
for _, subnetID := range lbNet.Subnets {
672-
if s.ID != nil && subnetID == *s.ID {
673+
subnet, err := networkingService.GetSubnetByParam(&s)
674+
if s.ID != nil && subnetID == *s.ID && err == nil {
673675
matchFound = true
674676
lbNetStatus.Subnets = append(
675677
lbNetStatus.Subnets, infrav1.Subnet{
676-
ID: *s.ID,
678+
ID: subnet.ID,
679+
Name: subnet.Name,
680+
CIDR: subnet.CIDR,
681+
Tags: subnet.Tags,
677682
})
678683
}
679684
}
@@ -682,6 +687,8 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
682687
return fmt.Errorf("no subnet match was found in the specified network (specified subnet: %v, available subnets: %v)", s, lbNet.Subnets)
683688
}
684689
}
690+
691+
openStackCluster.Status.APIServerLoadBalancer.LoadBalancerNetwork = lbNetStatus
685692
}
686693
}
687694

pkg/cloud/services/loadbalancer/loadbalancer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,11 @@ func (s *Service) getOrCreateAPILoadBalancer(openStackCluster *infrav1.OpenStack
294294
if vipNetworkID == "" && vipSubnetID == "" {
295295
// keep the default and create the VIP on the first cluster subnet
296296
vipSubnetID = openStackCluster.Status.Network.Subnets[0].ID
297+
s.scope.Logger().Info("No load balancer network specified, creating load balancer in the default subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
298+
} else {
299+
s.scope.Logger().Info("Creating load balancer in subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
297300
}
298301

299-
s.scope.Logger().Info("Creating load balancer in subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
300-
301302
providers, err := s.loadbalancerClient.ListLoadBalancerProviders()
302303
if err != nil {
303304
return nil, err

0 commit comments

Comments
 (0)