kubernetes/kops · error

getting load-balancer %s: %w

Error message

getting load-balancer %s: %w

What it means

kOps wraps failures from `lbService.ListLBs` when the LoadBalancer task's Find locates the cluster's Scaleway load-balancer by name (paging through all pages). Note the message prints l.LBID, though the search is by Name. The error comes from the Scaleway LB Zoned API; 'not found' alone does NOT throw (TotalCount != 1 returns nil, nil). Thrown in Find of loadbalancer.go.

Source

Thrown at upup/pkg/fi/cloudup/scalewaytasks/loadbalancer.go:77

	return l.LBID
}

// GetWellKnownServices implements fi.HasAddress::GetWellKnownServices.
// It indicates which services we support with this load balancer.
func (l *LoadBalancer) GetWellKnownServices() []wellknownservices.WellKnownService {
	return l.WellKnownServices
}

func (l *LoadBalancer) Find(context *fi.CloudupContext) (*LoadBalancer, error) {
	cloud := context.T.Cloud.(scaleway.ScwCloud)
	lbService := cloud.LBService()

	lbResponse, err := lbService.ListLBs(&lb.ZonedAPIListLBsRequest{
		Zone: scw.Zone(cloud.Zone()),
		Name: l.Name,
	}, scw.WithAllPages())
	if err != nil {
		return nil, fmt.Errorf("getting load-balancer %s: %w", fi.ValueOf(l.LBID), err)
	}
	if lbResponse.TotalCount != 1 {
		return nil, nil
	}
	loadBalancer := lbResponse.LBs[0]

	lbIPs := []string(nil)
	for _, IP := range loadBalancer.IP {
		lbIPs = append(lbIPs, IP.IPAddress)
	}

	return &LoadBalancer{
		Name:              new(loadBalancer.Name),
		LBID:              new(loadBalancer.ID),
		Zone:              new(string(loadBalancer.Zone)),
		LBAddresses:       lbIPs,
		Tags:              loadBalancer.Tags,
		Lifecycle:         l.Lifecycle,

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Rerun `kops update cluster` — often transient
  2. Verify the LB exists in the Scaleway console in the zone configured for the cloud
  3. Check Scaleway credentials and project permissions for the LB API
  4. Inspect the wrapped scw error (404/403/429/5xx) for the precise cause
  5. If the zone is wrong, fix the cluster's zone configuration and re-run update

Example fix

// before: message uses LBID while searching by name
return nil, fmt.Errorf("getting load-balancer %s: %w", fi.ValueOf(l.LBID), err)
// after: include both name and zone for diagnosability
return nil, fmt.Errorf("getting load-balancer %q in zone %s: %w", l.Name, scw.Zone(cloud.Zone()), err)
Defensive patterns

Strategy: type-guard

Validate before calling

// check zone and credentials before listing LBs
if cloud.Zone() == "" { return errors.New("cloud zone not set; cannot locate load-balancer") }
if l.Name == "" && fi.ValueOf(l.LBID) == "" { return errors.New("neither LB name nor LBID configured") }

Type guard

func lbAPIError(err error) (status int, ok bool) {
    var serr *scw.ResponseError
    if errors.As(err, &serr) { return serr.Status, true }
    return 0, false
}

Try / catch

if err != nil {
    if s, ok := lbAPIError(err); ok && s == 403 {
        return nil, fmt.Errorf("check Scaleway credentials for LB API: %w", err)
    }
    return nil, fmt.Errorf("getting load-balancer %q in zone %s: %w", l.Name, cloud.Zone(), err)
}

Prevention

When it happens

Trigger: Find calls ListLBs with Zone=scw.Zone(cloud.Zone()) and Name=l.Name, using WithAllPages; the listing call fails — invalid zone, auth failure, API outage, or rate limiting during pagination.

Common situations: Cloud zone configuration doesn't match where the LB is provisioned; expired/insufficient credentials; Scaleway API incident; LB deleted out-of-band (returns nil instead, but related calls may error).

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/7ce30fe33183ac3f. Report an issue: GitHub.