{"record":{"id":"7949b3a7016bd3dd","repo":"kubernetes/kops","slug":"failed-to-get-machine-type-w","errorCode":null,"errorMessage":"failed to get machine type: %w","messagePattern":"failed to get machine type: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"upup/pkg/fi/nodeup/command.go","lineNumber":266,"sourceCode":"\tswitch bootConfig.CloudProvider {\n\tcase api.CloudProviderAWS:\n\t\tinstanceIDBytes, err := vfs.Context.ReadFile(\"metadata://aws/meta-data/instance-id\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error reading instance-id from AWS metadata: %v\", err)\n\t\t}\n\t\tmodelContext.InstanceID = string(instanceIDBytes)\n\n\t\t// Check if WarmPool is enabled first, to avoid additional API calls\n\t\tif len(modelContext.NodeupConfig.WarmPoolImages) > 0 {\n\t\t\tmodelContext.ConfigurationMode, err = getAWSConfigurationMode(ctx, modelContext)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tmodelContext.MachineType, err = getMachineType(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get machine type: %w\", err)\n\t\t}\n\n\t\t// If Nvidia is enabled in the cluster, check if this instance has support for it.\n\t\tnvidia := modelContext.NodeupConfig.ContainerdConfig.NvidiaGPU\n\t\tif nvidia != nil && fi.ValueOf(nvidia.Enabled) {\n\t\t\t// Get the instance type's detailed information.\n\t\t\tinstanceType, err := cloud.GetMachineTypeInfo(ctx, ec2types.InstanceType(modelContext.MachineType))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif instanceType.GPU {\n\t\t\t\tklog.Info(\"instance supports GPU acceleration\")\n\t\t\t\tmodelContext.GPUVendor = architectures.GPUVendorNvidia\n\t\t\t}\n\t\t}\n\tcase api.CloudProviderOpenstack:\n\t\t// NvidiaGPU possible to enable only in instance group level in OpenStack. When we assume that GPU is supported","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/command.go#L248-L284","documentation":"After fetching the instance-id, the AWS branch of Run() calls getMachineType(ctx), which loads an AWS SDK config and queries the EC2 Instance Metadata Service for instance-type. Any failure there (config load failure or IMDS request failure) is wrapped as \"failed to get machine type\". nodeup needs the machine type to pick architecture-specific images and GPU support, so bootstrap stops.","triggerScenarios":"getMachineType(ctx) fails: awsconfig.LoadDefaultConfig errors (no credentials/region resolution) or imds.GetMetadata(\"instance-type\") errors (IMDS unreachable, IMDSv2 token issues, metadata disabled).","commonSituations":"Node running with IMDS hop-limit 1 inside a container; IMDS disabled via instance metadata options; SDK unable to resolve a region because no region is configured anywhere; running nodeup off-EC2 with the AWS provider.","solutions":["Test IMDS directly: curl -s -H 'X-aws-ec2-metadata-token: <token>' http://169.254.169.254/latest/meta-data/instance-type","Raise the IMDSv2 hop limit to 2 if nodeup runs in a container (aws ec2 modify-instance-metadata-options --http-put-response-hop-limit 2)","Ensure the node has a region resolvable (AWS_REGION env or instance-level default) so LoadDefaultConfig succeeds","Confirm instance metadata options have HttpEnabled=true"],"exampleFix":"// before: hop-limit 1 blocks SDK IMDSv2 calls from a container\n// after\naws ec2 modify-instance-metadata-options --instance-id i-0abc123 \\\n  --http-put-response-hop-limit 2 --http-tokens required","handlingStrategy":"retry","validationCode":"TOKEN=$(curl -sX PUT 'http://169.254.169.254/latest/api/token' -H 'X-aws-ec2-metadata-token-ttl-seconds: 60') && curl -s -H \"X-aws-ec2-metadata-token: $TOKEN\" http://169.254.169.254/latest/meta-data/instance-type","typeGuard":null,"tryCatchPattern":"if err := nodeupCmd.Run(ctx); err != nil {\n    var retryable = strings.Contains(err.Error(), \"failed to get machine type\")\n    if retryable {\n        return backoffRetry(nodeupCmd.Run, 3)\n    }\n    return err\n}","preventionTips":["Set a resolvable AWS region (AWS_REGION or instance profile defaults) on nodes","Raise IMDSv2 hop limit to 2 for containerized workloads","Ensure instance metadata options keep HttpEnabled=true","Test metadata access in node userdata before launching nodeup"],"tags":["aws","metadata","imds","machine-type","nodeup"],"backgroundTag":"ec2-metadata-unreachable","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"}