kubernetes/kops · error

error deleting RouteTable %q: %v

Error message

error deleting RouteTable %q: %v

What it means

kOps wraps failures from the EC2 DeleteRouteTable API. Errors classified as dependency violations are returned unwrapped so the caller's retry loop can back off; all other errors are wrapped with the route table ID. It means the route table could not be deleted for a non-dependency reason.

Source

Thrown at pkg/resources/aws/aws.go:911

	c := cloud.(awsup.AWSCloud)

	id := r.ID

	klog.V(2).Infof("Deleting EC2 RouteTable %q", id)
	request := &ec2.DeleteRouteTableInput{
		RouteTableId: &id,
	}
	_, err := c.EC2().DeleteRouteTable(ctx, request)
	if err != nil {
		if awsup.AWSErrorCode(err) == "InvalidRouteTableID.NotFound" {
			klog.V(2).Infof("Got InvalidRouteTableID.NotFound error describing RouteTable %q; will treat as already-deleted", id)
			return nil
		}

		if IsDependencyViolation(err) {
			return err
		}
		return fmt.Errorf("error deleting RouteTable %q: %v", id, err)
	}
	return nil
}

// DescribeRouteTablesIgnoreTags returns all ec2.RouteTable, ignoring tags
func DescribeRouteTablesIgnoreTags(cloud fi.Cloud) ([]ec2types.RouteTable, error) {
	ctx := context.TODO()
	c := cloud.(awsup.AWSCloud)

	klog.V(2).Infof("Listing all RouteTables")
	request := &ec2.DescribeRouteTablesInput{}
	response, err := c.EC2().DescribeRouteTables(ctx, request)
	if err != nil {
		return nil, fmt.Errorf("error listing RouteTables: %v", err)
	}

	return response.RouteTables, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check if the route table already exists: `aws ec2 describe-route-tables --route-table-ids <id>`; if NotFound, it is already deleted — skip it
  2. If throttled, wait and retry; kOps callers retry on dependency violations automatically
  3. Verify IAM permissions for ec2:DeleteRouteTable on the route table ARN
  4. Re-run kOps delete; it is idempotent and will skip missing resources

Example fix

// before: assuming error means table still exists
return fmt.Errorf("error deleting RouteTable %q: %v", id, err)
// after: treat NotFound as success in caller
if awsup.AWSErrorCode(err) == "InvalidRouteTableID.NotFound" {
	return nil
}
Defensive patterns

Strategy: validation

Validate before calling

// confirm the route table still exists before deleting
out, err := c.EC2().DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{
	RouteTableIds: []string{id},
})
if err != nil { return err }
if len(out.RouteTables) == 0 {
	return nil // already deleted
}

Type guard

func routeTableExists(out *ec2.DescribeRouteTablesOutput) bool {
	return out != nil && len(out.RouteTables) == 1
}

Try / catch

if err != nil {
	if awsup.AWSErrorCode(err) == "InvalidRouteTableID.NotFound" {
		return nil // already deleted
	}
	if awserrors.IsDependencyViolation(err) {
		return err // let caller backoff-retry
	}
	return fmt.Errorf("error deleting RouteTable %q: %v", id, err)
}

Prevention

When it happens

Trigger: EC2 DeleteRouteTable returns an error other than a dependency violation: wrong/unknown route table ID (InvalidRouteTableID.NotFound is not special-cased here), throttling, or auth failure.

Common situations: The route table was already deleted by another process or a previous partial run, so the ID no longer exists; IAM policy lacks ec2:DeleteRouteTable; API throttling during bulk cluster teardown.

Related errors


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