{"record":{"id":"d02867572184ec49","repo":"kubernetes/kops","slug":"failed-to-list-backend-services-w","errorCode":null,"errorMessage":"failed to list backend services: %w","messagePattern":"failed to list backend services: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/gce/gce.go","lineNumber":1098,"sourceCode":"\t\t}\n\n\t\tif !listed {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc (d *clusterDiscoveryGCE) listBackendServices() ([]*resources.Resource, error) {\n\tc := d.gceCloud\n\n\tsvcs, err := c.Compute().RegionBackendServices().List(context.Background(), c.Project(), c.Region())\n\tif err != nil {\n\t\tif gce.IsNotFound(err) {\n\t\t\tklog.Infof(\"BackendService not found, assuming none exist in project: %q region: %q\", c.Project(), c.Region())\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to list backend services: %w\", err)\n\t}\n\t// TODO: cache, for efficiency, if needed.\n\t// Find all relevant backend services by finding all the cluster's IGMs, and then\n\t// listing all backend services in the project / region, then selecting\n\t// the backend services which contain only the relevant IGMs.\n\tigms, err := d.listInstanceGroupManagersAndInstances()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar bs []*resources.Resource\n\tfor _, svc := range svcs {\n\t\tif containsOnlyListedIGMs(svc, igms) {\n\t\t\tresourceTracker := &resources.Resource{\n\t\t\t\tName: svc.Name,\n\t\t\t\tID:   svc.Name,\n\t\t\t\tType: typeBackendService,\n\t\t\t\tDeleter: func(cloud fi.Cloud, r *resources.Resource) error {\n\t\t\t\t\top, err := c.Compute().RegionBackendServices().Delete(c.Project(), c.Region(), svc.Name)","sourceCodeStart":1080,"sourceCodeEnd":1116,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/gce/gce.go#L1080-L1116","documentation":"Thrown by listBackendServices when RegionBackendServices().List fails with a non-NotFound error. This listing is used (from listHealthchecks) to discover health checks referenced by the cluster's backend services during teardown.","triggerScenarios":"RegionBackendServices().List(project, region) returns 403 (no compute.backendServices.list permission), invalid region, Compute API disabled/quota issues, or transient 5xx. NotFound is deliberately treated as 'none exist', so only genuine errors reach this message.","commonSituations":"Deletion credentials lacking compute viewer roles; cluster spec's region doesn't exist in the project; Compute API temporarily unavailable mid-teardown; cross-project credential confusion.","solutions":["Read the wrapped error for status code and details.","Verify the region matches the cluster spec and the project has the Compute API enabled.","Grant compute.networkViewer (backendServices.list) to the credentials.","Retry on transient 429/5xx errors."],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"failed to list backend services: %w\", err)\n// after\nreturn nil, fmt.Errorf(\"failed to list backend services in %s/%s: %w\", c.Project(), c.Region(), err)","handlingStrategy":"retry","validationCode":"// preflight: region and API availability\nsvc, err := computeClient.RegionBackendServices.List(project, region).Do()\nif err != nil {\n\treturn fmt.Errorf(\"preflight backend service list failed in %s/%s: %w\", project, region, err)\n}","typeGuard":"func isTransientAPIError(err error) bool {\n\tge, ok := err.(*googleapi.Error)\n\treturn ok && (ge.Code == 429 || ge.Code >= 500)\n}","tryCatchPattern":"svcs, err := c.Compute().RegionBackendServices().List(ctx, project, region)\nif err != nil {\n\tif gce.IsNotFound(err) {\n\t\treturn nil, nil\n\t}\n\tif isTransientAPIError(err) {\n\t\treturn retryWithBackoff(func() ([]*resources.Resource, error) { return listBackendServices(d) })\n\t}\n\treturn nil, fmt.Errorf(\"failed to list backend services: %w\", err)\n}","preventionTips":["Confirm compute.googleapis.com is enabled and billing active.","Grant compute.networkViewer for listing.","Validate the region value in the cluster spec matches a real GCE region."],"tags":["gce","backend-service","load-balancer","listing"],"backgroundTag":"gce-api-list-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}