Skip to content

Commit 0714d36

Browse files
committed
🐛 fix: additional control plane LBs must use correct subnets.
The additional (non-primary) Control planes with schema different than the primary are getting incorrect subnets. The fix makes sure that the schema for the lbSpec is checked, instead of the primary. Considering we can access the lbSpec locally, we no longer need the function ControlPlaneLoadBalancerScheme.
1 parent 3a00c39 commit 0714d36

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

pkg/cloud/scope/cluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ func (s *ClusterScope) ControlPlaneLoadBalancers() []*infrav1.AWSLoadBalancerSpe
193193
}
194194

195195
// ControlPlaneLoadBalancerScheme returns the Classic ELB scheme (public or internal facing).
196+
// Deprecated: This method is going to be removed in a future release. Use LoadBalancer.Scheme.
196197
func (s *ClusterScope) ControlPlaneLoadBalancerScheme() infrav1.ELBScheme {
197198
if s.ControlPlaneLoadBalancer() != nil && s.ControlPlaneLoadBalancer().Scheme != nil {
198199
return *s.ControlPlaneLoadBalancer().Scheme

pkg/cloud/scope/elb.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type ELBScope interface {
4343
ControlPlaneLoadBalancer() *infrav1.AWSLoadBalancerSpec
4444

4545
// ControlPlaneLoadBalancerScheme returns the Classic ELB scheme (public or internal facing)
46+
// Deprecated: This method is going to be removed in a future release. Use LoadBalancer.Scheme.
4647
ControlPlaneLoadBalancerScheme() infrav1.ELBScheme
4748

4849
// ControlPlaneLoadBalancerName returns the Classic ELB name

pkg/cloud/services/elb/loadbalancer.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (s *Service) getAPIServerLBSpec(elbName string, lbSpec *infrav1.AWSLoadBala
250250
// The load balancer APIs require us to only attach one subnet for each AZ.
251251
subnets := s.scope.Subnets().FilterPrivate()
252252

253-
if s.scope.ControlPlaneLoadBalancerScheme() == infrav1.ELBSchemeInternetFacing {
253+
if scheme == infrav1.ELBSchemeInternetFacing {
254254
subnets = s.scope.Subnets().FilterPublic()
255255
}
256256

@@ -989,9 +989,14 @@ func (s *Service) getAPIServerClassicELBSpec(elbName string) (*infrav1.LoadBalan
989989
}
990990
securityGroupIDs = append(securityGroupIDs, s.scope.SecurityGroups()[infrav1.SecurityGroupAPIServerLB].ID)
991991

992+
scheme := infrav1.ELBSchemeInternetFacing
993+
if controlPlaneLoadBalancer != nil && controlPlaneLoadBalancer.Scheme != nil {
994+
scheme = *controlPlaneLoadBalancer.Scheme
995+
}
996+
992997
res := &infrav1.LoadBalancer{
993998
Name: elbName,
994-
Scheme: s.scope.ControlPlaneLoadBalancerScheme(),
999+
Scheme: scheme,
9951000
ClassicELBListeners: []infrav1.ClassicELBListener{
9961001
{
9971002
Protocol: infrav1.ELBProtocolTCP,
@@ -1044,7 +1049,7 @@ func (s *Service) getAPIServerClassicELBSpec(elbName string) (*infrav1.LoadBalan
10441049
// The load balancer APIs require us to only attach one subnet for each AZ.
10451050
subnets := s.scope.Subnets().FilterPrivate()
10461051

1047-
if s.scope.ControlPlaneLoadBalancerScheme() == infrav1.ELBSchemeInternetFacing {
1052+
if scheme == infrav1.ELBSchemeInternetFacing {
10481053
subnets = s.scope.Subnets().FilterPublic()
10491054
}
10501055

0 commit comments

Comments
 (0)