{"record":{"id":"f6c06750d8820656","repo":"kubernetes/kops","slug":"failed-to-get-info-for-server-q-w-f6c067","errorCode":null,"errorMessage":"failed to get info for server %q: %w","messagePattern":"failed to get info for server %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/hetzner/cloud.go","lineNumber":276,"sourceCode":"\n\treturn err\n}\n\n// deleteServer shuts down and deletes the given server\nfunc deleteServer(c *hetznerCloudImplementation, id int64) error {\n\tclient := c.ServerClient()\n\tctx := context.TODO()\n\n\tserver := &hcloud.Server{ID: id}\n\t_, _, err := client.Shutdown(ctx, server)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to stop server %q: %w\", strconv.FormatInt(id, 10), err)\n\t}\n\n\tfor i := 1; i <= 30; i++ {\n\t\tserver, _, err := client.GetByID(ctx, id)\n\t\tif err != nil || server == nil {\n\t\t\treturn fmt.Errorf(\"failed to get info for server %q: %w\", strconv.FormatInt(id, 10), err)\n\t\t}\n\n\t\tif server.Status == hcloud.ServerStatusOff {\n\t\t\tbreak\n\t\t}\n\n\t\ttime.Sleep(time.Second * 5)\n\t}\n\n\t_, err = client.Delete(ctx, server)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete server %q: %w\", strconv.FormatInt(id, 10), err)\n\t}\n\n\treturn nil\n}\n\nfunc (c *hetznerCloudImplementation) DetachInstance(instance *cloudinstances.CloudInstance) error {","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/hetzner/cloud.go#L258-L294","documentation":"After issuing Shutdown, deleteServer polls client.GetByID up to 30 times waiting for the server to reach status 'off'; this error is thrown when GetByID returns an error or a nil server during that poll loop.","triggerScenarios":"The server is deleted out-of-band during the wait (GetByID returns nil), the API token becomes invalid mid-loop, rate limiting kicks in after repeated polling, or a network error occurs while polling.","commonSituations":"Slow shutdown exceeding the 150s poll window combined with an external deletion, hcloud API flakiness, or rate limit from frequent GetByID calls on large rolling updates.","solutions":["Re-check whether the server exists; treat nil server as already gone and proceed to delete/reconcile","Back off / add rate-limit handling in polling (the loop sleeps 5s per iteration but can still trip limits)","Retry the whole DeleteInstance operation after transient failures","Verify token validity and network stability during long-running operations"],"exampleFix":"// before\nif err != nil || server == nil {\n\treturn fmt.Errorf(\"failed to get info for server %q: %w\", strconv.FormatInt(id, 10), err)\n}\n// after\nif err != nil {\n\treturn fmt.Errorf(\"failed to get info for server %q: %w\", strconv.FormatInt(id, 10), err)\n}\nif server == nil {\n\treturn nil // server already gone, nothing to delete\n}","handlingStrategy":"retry","validationCode":"// before polling, confirm the server exists and is shutting down\nserver, _, err := client.GetByID(ctx, id)\nif err == nil && server != nil && server.Status == hcloud.ServerStatusOff {\n\treturn nil\n}","typeGuard":"func serverReachedStatus(client *hcloud.ServerClient, id int64, want hcloud.ServerStatus) (bool, error) {\n\ts, _, err := client.GetByID(context.TODO(), id)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif s == nil {\n\t\treturn true, nil // gone: nothing to wait for\n\t}\n\treturn s.Status == want, nil\n}","tryCatchPattern":"server, _, err := client.GetByID(ctx, id)\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\tcontinue\n\t}\n\treturn fmt.Errorf(\"failed to get info for server %q: %w\", strconv.FormatInt(id, 10), err)\n}","preventionTips":["Handle rate limits inside long poll loops","Treat nil server during polling as already-deleted rather than erroring","Use context timeouts instead of fixed 30-iteration loops","Monitor API health during large rolling updates"],"tags":["hetzner","api","server","polling"],"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-12T12:17:11.808Z"}