{"record":{"id":"74a5937fb461b629","repo":"kubernetes/kops","slug":"error-deleting-routetable-q-v","errorCode":null,"errorMessage":"error deleting RouteTable %q: %v","messagePattern":"error deleting RouteTable %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":911,"sourceCode":"\tc := cloud.(awsup.AWSCloud)\n\n\tid := r.ID\n\n\tklog.V(2).Infof(\"Deleting EC2 RouteTable %q\", id)\n\trequest := &ec2.DeleteRouteTableInput{\n\t\tRouteTableId: &id,\n\t}\n\t_, err := c.EC2().DeleteRouteTable(ctx, request)\n\tif err != nil {\n\t\tif awsup.AWSErrorCode(err) == \"InvalidRouteTableID.NotFound\" {\n\t\t\tklog.V(2).Infof(\"Got InvalidRouteTableID.NotFound error describing RouteTable %q; will treat as already-deleted\", id)\n\t\t\treturn nil\n\t\t}\n\n\t\tif IsDependencyViolation(err) {\n\t\t\treturn err\n\t\t}\n\t\treturn fmt.Errorf(\"error deleting RouteTable %q: %v\", id, err)\n\t}\n\treturn nil\n}\n\n// DescribeRouteTablesIgnoreTags returns all ec2.RouteTable, ignoring tags\nfunc DescribeRouteTablesIgnoreTags(cloud fi.Cloud) ([]ec2types.RouteTable, error) {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\n\tklog.V(2).Infof(\"Listing all RouteTables\")\n\trequest := &ec2.DescribeRouteTablesInput{}\n\tresponse, err := c.EC2().DescribeRouteTables(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing RouteTables: %v\", err)\n\t}\n\n\treturn response.RouteTables, nil\n}","sourceCodeStart":893,"sourceCodeEnd":929,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L893-L929","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check if the route table already exists: `aws ec2 describe-route-tables --route-table-ids <id>`; if NotFound, it is already deleted — skip it","If throttled, wait and retry; kOps callers retry on dependency violations automatically","Verify IAM permissions for ec2:DeleteRouteTable on the route table ARN","Re-run kOps delete; it is idempotent and will skip missing resources"],"exampleFix":"// before: assuming error means table still exists\nreturn fmt.Errorf(\"error deleting RouteTable %q: %v\", id, err)\n// after: treat NotFound as success in caller\nif awsup.AWSErrorCode(err) == \"InvalidRouteTableID.NotFound\" {\n\treturn nil\n}","handlingStrategy":"validation","validationCode":"// confirm the route table still exists before deleting\nout, err := c.EC2().DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{\n\tRouteTableIds: []string{id},\n})\nif err != nil { return err }\nif len(out.RouteTables) == 0 {\n\treturn nil // already deleted\n}","typeGuard":"func routeTableExists(out *ec2.DescribeRouteTablesOutput) bool {\n\treturn out != nil && len(out.RouteTables) == 1\n}","tryCatchPattern":"if err != nil {\n\tif awsup.AWSErrorCode(err) == \"InvalidRouteTableID.NotFound\" {\n\t\treturn nil // already deleted\n\t}\n\tif awserrors.IsDependencyViolation(err) {\n\t\treturn err // let caller backoff-retry\n\t}\n\treturn fmt.Errorf(\"error deleting RouteTable %q: %v\", id, err)\n}","preventionTips":["Always run kops delete a second time; it is idempotent for missing resources","Verify IAM permissions include ec2:DeleteRouteTable before teardown","Check `aws ec2 describe-route-tables` to see if another operator already removed it","Avoid deleting VPC resources manually alongside a kOps delete"],"tags":["aws","ec2","route-table","delete"],"backgroundTag":"aws-api-request-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}