{"record":{"id":"ba23e9805d11abb8","repo":"kubernetes/kops","slug":"failed-to-read-instance-metadata-response-w","errorCode":null,"errorMessage":"failed to read instance metadata response: %w","messagePattern":"failed to read instance metadata response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/command.go","lineNumber":427,"sourceCode":"func getMachineType(ctx context.Context) (string, error) {\n\tconfig, err := awsconfig.LoadDefaultConfig(ctx)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to load AWS config: %w\", err)\n\t}\n\n\tmetadata := imds.NewFromConfig(config)\n\n\t// Get the actual instance type by querying the EC2 instance metadata service.\n\tresult, err := metadata.GetMetadata(ctx, &imds.GetMetadataInput{\n\t\tPath: \"instance-type\",\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get instance metadata type: %w\", err)\n\t}\n\tdefer result.Content.Close()\n\tinstanceTypeName, err := io.ReadAll(result.Content)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to read instance metadata response: %w\", err)\n\t}\n\treturn string(instanceTypeName), err\n}\n\nfunc completeWarmingLifecycleAction(ctx context.Context, cloud *awsup.Cloud, modelContext *model.NodeupModelContext) error {\n\tasgName := modelContext.BootConfig.InstanceGroupName + \".\" + modelContext.NodeupConfig.ClusterName\n\thookName := \"kops-warmpool\"\n\thooks, err := cloud.DescribeLifecycleHooks(ctx, &autoscaling.DescribeLifecycleHooksInput{\n\t\tAutoScalingGroupName: &asgName,\n\t\tLifecycleHookNames:   []string{hookName},\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to find lifecycle hook %q: %w\", hookName, err)\n\t}\n\n\tif len(hooks.LifecycleHooks) > 0 {\n\t\tklog.Info(\"Found ASG lifecycle hook\")\n\t\t_, err := cloud.CompleteLifecycleAction(ctx, &autoscaling.CompleteLifecycleActionInput{","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/command.go#L409-L445","documentation":"GetMetadata succeeded but reading the response body stream (result.Content) with io.ReadAll failed, so nodeup cannot convert the body into the instance-type string. This wraps the underlying io read error.","triggerScenarios":"io.ReadAll(result.Content) errors after a successful metadata.GetMetadata call — the response stream was aborted or reset mid-read (connection reset, proxy interference, timeout).","commonSituations":"Intermediary (proxy or security agent) truncating link-local HTTP traffic; IMDS connection reset under heavy concurrent metadata queries at boot; buggy transparent MITM firewall on the node.","solutions":["Retry nodeup; this is typically transient and a fresh run re-reads the metadata cleanly.","Remove any transparent proxy/interception rules on traffic to 169.254.169.254.","Check IMDS response packet limits (--http-put-response-hop-limit / MTU issues on the metadata link).","If persistent, capture traffic to the metadata endpoint to identify the interfering component."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"body, err := io.ReadAll(result.Content)\nif err != nil {\n    if errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.ECONNRESET) {\n        // transient stream abort: retry the whole metadata call once\n    }\n    return fmt.Errorf(\"failed to read instance metadata response: %w\", err)\n}","preventionTips":["Remove transparent proxies/MITM agents intercepting link-local traffic.","Retry nodeup on transient failures before investigating deeper.","Check MTU on the metadata path if truncation recurs.","Ensure result.Content.Close (deferred) runs only after successful reads."],"tags":["aws","imds","io","nodeup"],"backgroundTag":"metadata-response-read-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"}