Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix: create lbaas in specified subnet #2339

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions controllers/openstackcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,15 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
for _, s := range lbSpec.Subnets {
matchFound := false
for _, subnetID := range lbNet.Subnets {
if s.ID != nil && subnetID == *s.ID {
subnet, err := networkingService.GetSubnetByParam(&s)
if s.ID != nil && subnetID == *s.ID && err == nil {
matchFound = true
lbNetStatus.Subnets = append(
lbNetStatus.Subnets, infrav1.Subnet{
ID: *s.ID,
ID: subnet.ID,
Name: subnet.Name,
CIDR: subnet.CIDR,
Tags: subnet.Tags,
})
}
}
Expand All @@ -640,6 +644,8 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
return fmt.Errorf("no subnet match was found in the specified network (specified subnet: %v, available subnets: %v)", s, lbNet.Subnets)
}
}

openStackCluster.Status.APIServerLoadBalancer.LoadBalancerNetwork = lbNetStatus
}
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/cloud/services/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,11 @@ func (s *Service) getOrCreateAPILoadBalancer(openStackCluster *infrav1.OpenStack
if vipNetworkID == "" && vipSubnetID == "" {
// keep the default and create the VIP on the first cluster subnet
vipSubnetID = openStackCluster.Status.Network.Subnets[0].ID
s.scope.Logger().Info("No load balancer network specified, creating load balancer in the default subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
} else {
s.scope.Logger().Info("Creating load balancer in subnet", "subnetID", vipSubnetID, "name", loadBalancerName)
}

s.scope.Logger().Info("Creating load balancer in subnet", "subnetID", vipSubnetID, "name", loadBalancerName)

providers, err := s.loadbalancerClient.ListLoadBalancerProviders()
if err != nil {
return nil, err
Expand Down