{"record":{"id":"73265b96570b8f97","repo":"kubernetes/kops","slug":"failed-to-get-load-balancers-matching-label-select","errorCode":null,"errorMessage":"failed to get load balancers matching label selector %q: %w","messagePattern":"failed to get load balancers matching label selector %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/hetzner/cloud.go","lineNumber":201,"sourceCode":"\t\treturn nil, fmt.Errorf(\"failed to get firewalls matching label selector %q: %w\", labelSelector, err)\n\t}\n\n\treturn matches, nil\n}\n\nfunc (c *hetznerCloudImplementation) GetLoadBalancers(clusterName string) ([]*hcloud.LoadBalancer, error) {\n\tclient := c.LoadBalancerClient()\n\n\tlabelSelector := TagKubernetesClusterName + \"=\" + clusterName\n\tlistOptions := hcloud.ListOpts{\n\t\tPerPage:       50,\n\t\tLabelSelector: labelSelector,\n\t}\n\tloadBalancerListOptions := hcloud.LoadBalancerListOpts{ListOpts: listOptions}\n\n\tmatches, err := client.AllWithOpts(context.TODO(), loadBalancerListOptions)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get load balancers matching label selector %q: %w\", labelSelector, err)\n\t}\n\n\treturn matches, nil\n}\n\nfunc (c *hetznerCloudImplementation) GetServers(clusterName string) ([]*hcloud.Server, error) {\n\tclient := c.ServerClient()\n\n\tlabelSelector := TagKubernetesClusterName + \"=\" + clusterName\n\tlistOptions := hcloud.ListOpts{\n\t\tPerPage:       50,\n\t\tLabelSelector: labelSelector,\n\t}\n\tsortOptions := []string{\n\t\t\"created:desc\",\n\t}\n\tserverListOptions := hcloud.ServerListOpts{ListOpts: listOptions, Sort: sortOptions}\n","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/hetzner/cloud.go#L183-L219","documentation":"GetLoadBalancers wraps any error from hcloud LoadBalancerClient.AllWithOpts when listing load balancers filtered by the cluster label selector. It indicates the Hetzner Cloud API list request failed; the original hcloud error is wrapped.","triggerScenarios":"Calling GetLoadBalancers with an invalid/missing API token, network failure to api.hetzner.cloud, rate limiting (429), or a server-side 5xx during paginated AllWithOpts listing.","commonSituations":"kOps validate or delete operations on a Hetzner cluster when the token was rotated or project deleted, or when Hetzner has a partial API outage affecting the load balancer endpoint.","solutions":["Verify HCLOUD_TOKEN is valid and scoped to the correct Hetzner project","Retry after the rate-limit window if the wrapped error is 429","Check Hetzner status page / API reachability for outages","Unwrap the error (errors.Unwrap) to see the specific hcloud.ErrorCode"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if os.Getenv(\"HCLOUD_TOKEN\") == \"\" {\n\treturn fmt.Errorf(\"HCLOUD_TOKEN must be set before calling GetLoadBalancers\")\n}","typeGuard":"var hcloudErr *hcloud.Error\nif errors.As(err, &hcloudErr) {\n\t// branch on hcloudErr.Code\n}","tryCatchPattern":"lbs, err := cloud.GetLoadBalancers(clusterName)\nif err != nil {\n\tvar hErr *hcloud.Error\n\tif errors.As(err, &hErr) && hErr.Code == hcloud.ErrorCodeRateLimit {\n\t\ttime.Sleep(hErr.RateLimit.RetryAfter())\n\t\tlbs, err = cloud.GetLoadBalancers(clusterName)\n\t}\n}","preventionTips":["Validate the token with a cheap API call (e.g. client.Server.List) before heavy operations","Back off on 429 before retrying list calls","Watch for token rotation in the Hetzner console","Confirm project/permissions when moving clusters between projects"],"tags":["hetzner","api","loadbalancer","network"],"backgroundTag":"hetzner-api-request-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"}