kubernetes/kops · error

error listing Akamai (Linode) VPCs: %w

Error message

error listing Akamai (Linode) VPCs: %w

What it means

This error wraps a failure from the Linode API ListVPCs call made by the VPC task's Find() when it searches for an existing VPC matching the task's label. It means the discovery/list phase failed before any matching logic ran; the raw linodego error (auth, network, rate limit, server error) is preserved via %w.

Source

Thrown at upup/pkg/fi/cloudup/linodetasks/vpc.go:59

func (v *VPC) CompareWithID() *string {
	if v.ID == nil {
		return nil
	}
	id := strconv.Itoa(fi.ValueOf(v.ID))
	return new(id)
}

func (v *VPC) Find(c *fi.CloudupContext) (*VPC, error) {
	cloud := c.T.Cloud.(linode.LinodeCloud)
	listOptions, err := linode.ListOptionsForLabel(fi.ValueOf(v.Name))
	if err != nil {
		return nil, err
	}

	vpcs, err := cloud.Client().ListVPCs(c.Context(), listOptions)
	if err != nil {
		return nil, fmt.Errorf("error listing Akamai (Linode) VPCs: %w", err)
	}

	var found *linodego.VPC
	name := fi.ValueOf(v.Name)
	for i := range vpcs {
		candidate := &vpcs[i]
		if candidate.Label != name {
			continue
		}
		if v.Region != nil && candidate.Region != fi.ValueOf(v.Region) {
			continue
		}
		if found != nil {
			return nil, fmt.Errorf("found multiple Akamai (Linode) VPCs named %q", name)
		}
		found = candidate
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify LINODE_TOKEN / API token validity and that it includes vpcs:read scope
  2. Check network connectivity/proxy settings to https://api.linode.com/v4
  3. Wait out Linode API rate limits (429) and reduce concurrent kops/API activity, then retry
  4. Retry on transient 5xx errors - Find() is read-only and safe to re-run
  5. Upgrade linodego/kops if the error indicates an API schema change

Example fix

// before: no pre-flight credential check
vpcs, err := cloud.Client().ListVPCs(c.Context(), listOptions)
// after: validate token once at target creation
if _, err := client.GetAccount(c.Context()); err != nil {
    return nil, fmt.Errorf("linode API token invalid: %w", err)
}
vpcs, err := cloud.Client().ListVPCs(c.Context(), listOptions)
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight check before the update run:
func checkLinodeAuth(ctx context.Context, client *linodego.Client) error {
    if _, err := client.GetAccount(ctx); err != nil {
        return fmt.Errorf("linode API token invalid or lacks vpcs:read scope: %w", err)
    }
    return nil
}

Type guard

func isRetryableAPIError(err error) bool {
    var apiErr *linodego.Error
    if errors.As(err, &apiErr) {
        return apiErr.Code == 429 || apiErr.Code >= 500
    }
    return false
}

Try / catch

if err := run(); err != nil {
    if isRetryableAPIError(err) {
        time.Sleep(backoff)
        return run()
    }
    var apiErr *linodego.Error
    if errors.As(err, &apiErr) && (apiErr.Code == 401 || apiErr.Code == 403) {
        return fmt.Errorf("fix LINODE_TOKEN / scopes: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: ListVPCs returns an error: invalid or expired API token (401), token lacking vpcs:read_only scope (403), API rate limiting (429), network connectivity failure, or a 500 from the Linode API while filtering by label via ListOptionsForLabel.

Common situations: Running kops update with credentials rotated/expired; corporate proxy or DNS outage blocking api.linode.com; heavy automation hitting the Linode API rate limit; token created without VPC read scope.

Related errors


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