kubernetes/kops · error

listing route tables: %w

Error message

listing route tables: %w

What it means

Wrapped error when a page of route table listing fails during pager.NextPage in routeTablesClientImpl.List. Note ResourceGroupNotFound is deliberately swallowed and returns an empty list; any other listing failure is wrapped here.

Source

Thrown at upup/pkg/fi/cloudup/azure/routetable.go:68

	}
	return &rt.RouteTable, err
}

func (c *routeTablesClientImpl) List(ctx context.Context, resourceGroupName string) ([]*network.RouteTable, error) {
	if resourceGroupName == "" {
		return nil, nil
	}

	var l []*network.RouteTable
	pager := c.c.NewListPager(resourceGroupName, nil)
	for pager.More() {
		resp, err := pager.NextPage(ctx)
		if err != nil {
			var respErr *azcore.ResponseError
			if errors.As(err, &respErr) && respErr.ErrorCode == "ResourceGroupNotFound" {
				return nil, nil
			}
			return nil, fmt.Errorf("listing route tables: %w", err)
		}
		l = append(l, resp.Value...)
	}
	return l, nil
}

func (c *routeTablesClientImpl) Delete(ctx context.Context, resourceGroupName, vnetName string) error {
	future, err := c.c.BeginDelete(ctx, resourceGroupName, vnetName, nil)
	if err != nil {
		return fmt.Errorf("deleting route table: %w", err)
	}
	if _, err := future.PollUntilDone(ctx, nil); err != nil {
		return fmt.Errorf("waiting for route table deletion completion: %w", err)
	}
	return nil
}

func newRouteTablesClientImpl(subscriptionID string, cred *azidentity.DefaultAzureCredential) (*routeTablesClientImpl, error) {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Grant the identity Reader/Network Contributor with routeTables/read access on the subscription or resource group
  2. Confirm AZURE_SUBSCRIPTION_ID matches where the cluster's resource group lives
  3. Retry on throttling (429) honoring Retry-After
  4. If the resource group truly should not exist, treat it like the already-handled ResourceGroupNotFound case
Defensive patterns

Strategy: try-catch

Validate before calling

if os.Getenv("AZURE_SUBSCRIPTION_ID") == "" {
	return fmt.Errorf("AZURE_SUBSCRIPTION_ID must be set")
}

Type guard

var respErr *azcore.ResponseError
if errors.As(err, &respErr) {
	if respErr.ErrorCode == "ResourceGroupNotFound" {
		return nil, nil // treat as empty
	}
}

Try / catch

rts, err := client.List(ctx, rg)
if err != nil {
	var respErr *azcore.ResponseError
	if errors.As(err, &respErr) && respErr.StatusCode == 403 {
		return fmt.Errorf("missing routeTables/read permission: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: pager.NextPage(ctx) returns an error other than ResourceGroupNotFound: auth failure (403), invalid subscription ID, throttling, or transient 5xx from the ARM list API.

Common situations: Service principal lacks Microsoft.Network/routeTables/read; wrong subscription configured; Azure outage or rate limiting during cluster status lookups.

Related errors


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