{"record":{"id":"8ac978b8a82d25c3","repo":"kubernetes/kops","slug":"reading-imds-response-w","errorCode":null,"errorMessage":"reading IMDS response: %w","messagePattern":"reading IMDS response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/azure/azuremetadata/imds.go","lineNumber":90,"sourceCode":"\n\tparams.Set(\"api-version\", imdsAPIVersion)\n\treq.URL.RawQuery = params.Encode()\n\n\tklog.V(4).Infof(\"Azure IMDS query: %q\", req.URL.String())\n\n\tresp, err := imdsHTTPClient.Do(req)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"querying IMDS %s: %w\", path, err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"querying IMDS %s: status %d\", path, resp.StatusCode)\n\t}\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading IMDS response: %w\", err)\n\t}\n\tklog.V(4).Infof(\"Azure IMDS response: %d bytes\", len(body))\n\n\tif err := json.Unmarshal(body, result); err != nil {\n\t\treturn fmt.Errorf(\"unmarshalling IMDS response: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// QueryComputeInstanceMetadata queries Azure IMDS for compute instance metadata.\n// https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service#instance-metadata\nfunc QueryComputeInstanceMetadata(ctx context.Context) (*InstanceMetadata, error) {\n\tmetadata := &InstanceMetadata{}\n\tparams := url.Values{\"format\": {\"json\"}}\n\tif err := queryIMDS(ctx, \"/metadata/instance/compute\", params, metadata); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/azure/azuremetadata/imds.go#L72-L108","documentation":"queryIMDS failed while reading the IMDS response body via io.ReadAll, wrapped as \"reading IMDS response\". This happens when the connection drops mid-response or the read exceeds the client's 10s timeout — the headers arrived but the body could not be fully read.","triggerScenarios":"io.ReadAll(resp.Body) returns an error for an IMDS response: abrupt connection reset, truncated response, or timeout during body transfer from /metadata/instance/compute or /metadata/attested/document.","commonSituations":"Flaky virtual network / NIC issues on the node; IMDS under extreme load closing connections; very short-lived transient network partitions.","solutions":["Retry the query — this is almost always transient; callers of CreateToken typically retry bootstrap","Check node network health (NIC, routes to link-local) if persistent","Inspect for middleboxes/firewalls resetting established connections to 169.254.169.254"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Body-read failures are transient: retry the whole query\nerr := retry.OnError(wait.Backoff{Steps: 4, Duration: time.Second, Factor: 2},\n    func(err error) bool { return strings.Contains(err.Error(), \"reading IMDS response\") },\n    func() error { _, err := auth.CreateToken(body); return err })","preventionTips":["Keep node NIC/drivers healthy; investigate persistent connection resets","Watch for middleboxes resetting link-local connections in hardened images","Always retry bootstrap token minting; single-shot calls will eventually hit this"],"tags":["azure","imds","network","io"],"backgroundTag":"connection-reset","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"}