Skip to content

Commit 53f3189

Browse files
authored
Merge pull request #2339 from simonostendorf/fix/create-lbaas-in-specified-subnet
🐛 fix: create lbaas in specified subnet
2 parents e4f56a2 + 8af5328 commit 53f3189

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

controllers/openstackcluster_controller.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,15 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
626626
for _, s := range lbSpec.Subnets {
627627
matchFound := false
628628
for _, subnetID := range lbNet.Subnets {
629-
if s.ID != nil && subnetID == *s.ID {
629+
subnet, err := networkingService.GetSubnetByParam(&s)
630+
if s.ID != nil && subnetID == *s.ID && err == nil {
630631
matchFound = true
631632
lbNetStatus.Subnets = append(
632633
lbNetStatus.Subnets, infrav1.Subnet{
633-
ID: *s.ID,
634+
ID: subnet.ID,
635+
Name: subnet.Name,
636+
CIDR: subnet.CIDR,
637+
Tags: subnet.Tags,
634638
})
635639
}
636640
}
@@ -639,6 +643,8 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
639643
return fmt.Errorf("no subnet match was found in the specified network (specified subnet: %v, available subnets: %v)", s, lbNet.Subnets)
640644
}
641645
}
646+
647+
openStackCluster.Status.APIServerLoadBalancer.LoadBalancerNetwork = lbNetStatus
642648
}
643649
}
644650

pkg/cloud/services/loadbalancer/loadbalancer.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,11 @@ func (s *Service) getOrCreateAPILoadBalancer(openStackCluster *infrav1.OpenStack
305305
if vipNetworkID == "" && vipSubnetID == "" {
306306
// keep the default and create the VIP on the first cluster subnet
307307
vipSubnetID = openStackCluster.Status.Network.Subnets[0].ID
308+
s.scope.Logger().Info("No load balancer network specified, creating load balancer in the default subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
309+
} else {
310+
s.scope.Logger().Info("Creating load balancer in subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
308311
}
309312

310-
s.scope.Logger().Info("Creating load balancer in subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
311-
312313
providers, err := s.loadbalancerClient.ListLoadBalancerProviders()
313314
if err != nil {
314315
return nil, err

0 commit comments

Comments
 (0)