{"record":{"id":"849453b47cacb949","repo":"kubernetes/kops","slug":"building-blockdevicemappings-for-q-w","errorCode":null,"errorMessage":"building blockDeviceMappings for %q: %w","messagePattern":"building blockDeviceMappings for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions_karpenter.go","lineNumber":244,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building tags for %q: %w\", ig.Name, err)\n\t}\n\ttags = karpenterEC2NodeClassTags(tags)\n\tassociatePublicIP, err := tf.karpenterAssociatePublicIP(ig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tuserData, err := tf.managedFileContents(\"nodeupscript-\" + ig.Name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading userData for %q: %w\", ig.Name, err)\n\t}\n\trootDeviceName, err := tf.karpenterRootDeviceName(ig.Spec.Image)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"resolving root device for %q: %w\", ig.Name, err)\n\t}\n\tblockDeviceMappings, err := buildKarpenterBlockDeviceMappings(ig, rootDeviceName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building blockDeviceMappings for %q: %w\", ig.Name, err)\n\t}\n\n\tsubnetTerms := []karpenterSelectorTerm{\n\t\t{\n\t\t\tTags: map[string]string{\n\t\t\t\t\"KubernetesCluster\":                     tf.ClusterName(),\n\t\t\t\t\"kops.k8s.io/instance-group/\" + ig.Name: \"true\",\n\t\t\t},\n\t\t},\n\t}\n\n\tsecurityGroupTerms := []karpenterSelectorTerm{}\n\tif ig.Spec.SecurityGroupOverride != nil {\n\t\tsecurityGroupTerms = append(securityGroupTerms, karpenterSelectorTerm{ID: fi.ValueOf(ig.Spec.SecurityGroupOverride)})\n\t} else {\n\t\tsecurityGroupTerms = append(securityGroupTerms, karpenterSelectorTerm{\n\t\t\tTags: map[string]string{\n\t\t\t\t\"KubernetesCluster\": tf.ClusterName(),","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions_karpenter.go#L226-L262","documentation":"Returned by buildKarpenterEC2NodeClass when buildKarpenterBlockDeviceMappings(ig, rootDeviceName) fails to construct the block device mappings for the instance group. This reflects invalid volume configuration on the instance group relative to the resolved root device.","triggerScenarios":"Instance group storage/volume spec values are invalid for building Karpenter blockDeviceMappings — e.g. nil/invalid rootVolume settings, unsupported volume type, or size/format values that cannot be translated.","commonSituations":"rootVolumeSize/rootVolumeType set to values unsupported by Karpenter mapping; volumes list with malformed entries; mixing volume settings incompatible with the image's root device.","solutions":["Check the wrapped error from buildKarpenterBlockDeviceMappings for the failing volume field","Validate instance group rootVolume* settings (size, type) are sane and supported","Remove or fix custom volumes entries incompatible with Karpenter mappings","Align volume config with the root device name resolved from the image"],"exampleFix":"// before\nrootVolumeSize: -10\nrootVolumeType: magic-ssd\n// after\nrootVolumeSize: 100\nrootVolumeType: gp3","handlingStrategy":"validation","validationCode":"// validate volume settings before rendering\nif ig.Spec.MachineType == \"\" || ig.Spec.RootVolumeSize <= 0 {\n\treturn fmt.Errorf(\"instance group %q has invalid volume configuration\", ig.Name)\n}","typeGuard":null,"tryCatchPattern":"nc, err := tf.KarpenterEC2NodeClass(ig)\nif err != nil {\n\treturn fmt.Errorf(\"blockDeviceMappings for %q failed: %w\", ig.Name, err)\n}","preventionTips":["Set sane rootVolumeSize (positive, within EBS limits) and a supported rootVolumeType","Avoid custom volumes entries incompatible with Karpenter mappings","Validate instance group storage specs during cluster spec validation","Add unit tests for buildKarpenterBlockDeviceMappings edge cases"],"tags":["karpenter","block-device","storage","kops"],"backgroundTag":"invalid-block-device-mapping","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"}