{"record":{"id":"ffea1b505924cb72","repo":"kubernetes/kops","slug":"error-checking-for-existing-routetableassociation","errorCode":null,"errorMessage":"error checking for existing RouteTableAssociation: %v","messagePattern":"error checking for existing RouteTableAssociation: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/routetableassociation.go","lineNumber":157,"sourceCode":"\t\treturn nil, nil\n\t}\n\n\tif len(response.RouteTables) != 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple RouteTables attached to subnet\")\n\t}\n\trt := response.RouteTables[0]\n\treturn &rt, nil\n}\n\nfunc (_ *RouteTableAssociation) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *RouteTableAssociation) error {\n\tctx := context.TODO()\n\tif a == nil {\n\t\t// TODO: We might do better just to make the subnet the primary key here\n\n\t\tklog.V(2).Infof(\"Checking for existing RouteTableAssociation to subnet\")\n\t\texisting, err := findExistingRouteTableForSubnet(t.Cloud, e.Subnet)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error checking for existing RouteTableAssociation: %v\", err)\n\t\t}\n\n\t\tif existing != nil {\n\t\t\tfor _, a := range existing.Associations {\n\t\t\t\tif aws.ToString(a.SubnetId) != aws.ToString(e.Subnet.ID) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tklog.V(2).Infof(\"Creating RouteTableAssociation\")\n\t\t\t\trequest := &ec2.DisassociateRouteTableInput{\n\t\t\t\t\tAssociationId: a.RouteTableAssociationId,\n\t\t\t\t}\n\n\t\t\t\t_, err := t.Cloud.EC2().DisassociateRouteTable(ctx, request)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error disassociating existing RouteTable from subnet: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/routetableassociation.go#L139-L175","documentation":"Wraps any error from findExistingRouteTableForSubnet during RouteTableAssociation RenderAWS when checking whether the subnet already has a route table association. It is a contextual wrapper — the root cause is inside (nil subnet, nil ID, or EC2 API failure).","triggerScenarios":"RenderAWS of a RouteTableAssociation task whose findExistingRouteTableForSubnet call returns an error (see errors 2090-2092) — it is then re-wrapped with this message.","commonSituations":"Same as root causes: deleted/stale subnets, EC2 API errors, multiple attached route tables; surfaced during kops update / cluster reconciliation.","solutions":["Inspect the inner error chained in the message for the real cause (subnet ID not set / listing error / multiple tables)","Fix per the underlying cause: restore subnet reference, fix IAM/throttling, or de-duplicate route table associations","Re-run kops update to re-reconcile"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=<subnet-id> --region <region>","typeGuard":null,"tryCatchPattern":"if err := update(); err != nil {\n  if strings.Contains(err.Error(), \"error checking for existing RouteTableAssociation\") {\n    log.Println(\"check inner cause; fix subnet references or IAM, then re-run\")\n  }\n}","preventionTips":["Fix the inner cause, not the wrapper: validate subnets and IAM first","Re-run kops update after resource drift","Avoid concurrent applies"],"tags":["aws","route-table","reconciliation","wrapper-error"],"backgroundTag":"route-table-association-check-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"}