Skip to content

Commit eb0cc32

Browse files
committed
Filter NodeBalancer lookup by frontend-subnet-id annotation when specified
Add logic to getNodeBalancerByIP to filter results from the NB list call by frontend-subnet-id annotation. When annotation is present, only return NodeBalancer matching the specified frontend VPC subnet ID. Return lbNotFoundError if no matching NodeBalancer found.
1 parent c0cf59d commit eb0cc32

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

cloud/linode/loadbalancers.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,17 @@ func (l *loadbalancers) getNodeBalancerByIP(ctx context.Context, service *v1.Ser
726726
if len(lbs) == 0 {
727727
return nil, lbNotFoundError{serviceNn: getServiceNn(service)}
728728
}
729+
730+
frontendSubnetID := service.GetAnnotations()[annotations.NodeBalancerFrontendSubnetID]
731+
if frontendSubnetID != "" {
732+
for _, NB := range lbs {
733+
if NB.FrontendVPCSubnetID != nil && strconv.Itoa(*NB.FrontendVPCSubnetID) == frontendSubnetID {
734+
return &NB, nil
735+
}
736+
}
737+
return nil, lbNotFoundError{serviceNn: getServiceNn(service)}
738+
}
739+
729740
klog.V(2).Infof("found NodeBalancer (%d) for service (%s) via IP (%s)", lbs[0].ID, getServiceNn(service), ip.String())
730741
return &lbs[0], nil
731742
}

0 commit comments

Comments
 (0)