Skip to content

Commit

Permalink
always return lbnotfound from getNodeBalancerForService
Browse files Browse the repository at this point in the history
  • Loading branch information
luthermonson committed Jan 14, 2024
1 parent 5572272 commit fa418e0
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions cloud/linode/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,13 @@ func newLoadbalancers(client Client, zone string) cloudprovider.LoadBalancer {
}

func (l *loadbalancers) getNodeBalancerForService(ctx context.Context, service *v1.Service) (*linodego.NodeBalancer, error) {
rawID, _ := getServiceAnnotation(service, annLinodeNodeBalancerID)
rawID := service.GetAnnotations()[annLinodeNodeBalancerID]
id, idErr := strconv.Atoi(rawID)
hasIDAnn := idErr == nil && id != 0

if hasIDAnn {
sentry.SetTag(ctx, "load_balancer_id", rawID)
nb, err := l.getNodeBalancerByID(ctx, service, id)
switch err.(type) {
case nil:
return nb, nil

case lbNotFoundError:
return nil, fmt.Errorf("%s annotation points to a NodeBalancer that does not exist: %s", annLinodeNodeBalancerID, err)

default:
return nil, err
}
return l.getNodeBalancerByID(ctx, service, id)
}
return l.getNodeBalancerByStatus(ctx, service)
}
Expand Down Expand Up @@ -199,6 +189,13 @@ func (l *loadbalancers) EnsureLoadBalancer(ctx context.Context, clusterName stri
nb, err = l.getNodeBalancerForService(ctx, service)
switch err.(type) {
case lbNotFoundError:
if service.GetAnnotations()[annLinodeNodeBalancerID] != "" {
// a load balancer annotation has been created so a NodeBalancer is coming, error out and retry later
klog.Infof("NodeBalancer created but not available yet, waiting...")
sentry.CaptureError(ctx, err)
return nil, err
}

if nb, err = l.buildLoadBalancerRequest(ctx, clusterName, service, nodes); err != nil {
sentry.CaptureError(ctx, err)
return nil, err
Expand Down

0 comments on commit fa418e0

Please sign in to comment.