{"record":{"id":"dca36a5af511cd19","repo":"kubernetes/kops","slug":"unexpected-number-of-nats-found-v","errorCode":null,"errorMessage":"unexpected number of nats found: %+v","messagePattern":"unexpected number of nats found: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/router.go","lineNumber":80,"sourceCode":"// CompareWithID returns the name of the Router.\nfunc (r *Router) CompareWithID() *string {\n\treturn r.Name\n}\n\n// Find discovers the Router in the cloud provider.\nfunc (r *Router) Find(c *fi.CloudupContext) (*Router, error) {\n\tcloud := c.T.Cloud.(gce.GCECloud)\n\n\tfound, err := cloud.Compute().Routers().Get(cloud.Project(), *r.Region, *r.Name)\n\tif err != nil {\n\t\tif gce.IsNotFound(err) {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"error listing Routers: %w\", err)\n\t}\n\n\tif len(found.Nats) != 1 {\n\t\treturn nil, fmt.Errorf(\"unexpected number of nats found: %+v\", found.Nats)\n\t}\n\tnat := found.Nats[0]\n\n\tif a, e := found.SelfLink, r.url(cloud.Project()); a != e {\n\t\tklog.Warningf(\"SelfLink did not match URL: %q vs %q\", a, e)\n\t}\n\n\tactual := &Router{\n\t\tName:                          &found.Name,\n\t\tLifecycle:                     r.Lifecycle,\n\t\tNetwork:                       &Network{Name: new(lastComponent(found.Network))},\n\t\tRegion:                        new(lastComponent(found.Region)),\n\t\tNATIPAllocationOption:         &nat.NatIpAllocateOption,\n\t\tSourceSubnetworkIPRangesToNAT: &nat.SourceSubnetworkIpRangesToNat,\n\t}\n\n\tfor _, subnet := range nat.Subnetworks {\n\t\tif strings.Join(subnet.SourceIpRangesToNat, \",\") != subnetNatAllIPRanges {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/router.go#L62-L98","documentation":"Validation error from Router.Find when the fetched router's NAT list does not contain exactly one entry. kOps models exactly one Cloud NAT config per router, so zero or multiple NATs (e.g. manually added ones) make the state unmanageable; the full NAT list is printed.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/gcetasks/router.go:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the printed NAT list and remove extra manually-created NATs from the router (or let kOps own it exclusively)","If no NAT exists, ensure the router task creates one by re-running apply from a clean state","Avoid mixing manual gcloud NAT edits with kOps-managed routers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}