{"record":{"id":"9dccab155378a3f3","repo":"kubernetes/kops","slug":"failed-to-read-q-from-ec2-meta-data-v","errorCode":null,"errorMessage":"failed to read %q from ec2 meta-data: %v","messagePattern":"failed to read %q from ec2 meta-data: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/nodetasks/prefix.go","lineNumber":140,"sourceCode":"func getInstanceMetadataList(ctx context.Context, category string) ([]string, error) {\n\tcfg, err := awsconfig.LoadDefaultConfig(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load aws config: %v\", err)\n\t}\n\tmetadata := imds.NewFromConfig(cfg)\n\tresp, err := metadata.GetMetadata(ctx, &imds.GetMetadataInput{Path: category})\n\tif err != nil {\n\t\tvar awsErr *smithyhttp.ResponseError\n\t\tif errors.As(err, &awsErr) && awsErr.HTTPStatusCode() == http.StatusNotFound {\n\t\t\treturn nil, nil\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"failed to get %q from ec2 meta-data: %v\", category, err)\n\t\t}\n\t}\n\tdefer resp.Content.Close()\n\tlines, err := io.ReadAll(resp.Content)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read %q from ec2 meta-data: %v\", category, err)\n\t}\n\n\tvar values []string\n\tfor _, line := range strings.Split(string(lines), \"\\n\") {\n\t\tline = strings.TrimSpace(line)\n\t\tif len(line) > 0 {\n\t\t\tvalues = append(values, line)\n\t\t}\n\t}\n\n\treturn values, nil\n}\n","sourceCodeStart":122,"sourceCodeEnd":153,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/nodetasks/prefix.go#L122-L153","documentation":"After a successful IMDS GetMetadata response, the body is read with io.ReadAll; if reading the response Content stream fails the error is wrapped as 'failed to read %q from ec2 meta-data'. This indicates the HTTP response began but the body could not be fully consumed.","triggerScenarios":"The IMDS HTTP response body errors mid-stream: connection reset, timeout while reading, or the response Content being nil/closed prematurely.","commonSituations":"Flaky link-local networking under load; IMDS connection timeouts on very busy nodes; proxies or agents intercepting 169.254.169.254 and truncating responses.","solutions":["Retry nodeup; transient IMDS stream errors usually clear on retry.","Verify nothing on the host intercepts 169.254.169.254 (iptables NAT rules, http_proxy with link-local in no_proxy).","Check for host-level network instability (conntrack exhaustion, NIC issues) around bootstrap time."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify IMDS reachable and stable before the call\nnet.DialTimeout(\"tcp\", \"169.254.169.254:80\", 2*time.Second)","typeGuard":null,"tryCatchPattern":"if err != nil && isTransient(err) { return retryWithBackoff(fn, 3) }","preventionTips":["Avoid proxies/NAT interception of link-local metadata traffic","Monitor host conntrack/NIC health during bootstrap","Retry bootstrap on transient IO errors"],"tags":["aws","imds","io","networking"],"backgroundTag":"instance-metadata-unavailable","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"}