{"record":{"id":"cad483277e832650","repo":"kubernetes/kops","slug":"building-tags-for-q-w","errorCode":null,"errorMessage":"building tags for %q: %w","messagePattern":"building tags for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions_karpenter.go","lineNumber":227,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"marshaling Karpenter resource for %q: %w\", ig.Name, err)\n\t}\n\treturn strings.TrimSpace(string(data)), nil\n}\n\nfunc (tf *TemplateFunctions) buildKarpenterEC2NodeClass(ig *kops.InstanceGroup) (*karpenterEC2NodeClass, error) {\n\tamiSelectorTerms, err := buildKarpenterAMITerms(ig.Spec.Image)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building amiSelectorTerms for %q: %w\", ig.Name, err)\n\t}\n\n\tinstanceProfile, err := tf.LinkToIAMInstanceProfile(ig)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building instance profile for %q: %w\", ig.Name, err)\n\t}\n\n\ttags, err := tf.CloudTagsForInstanceGroup(ig)\n\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}","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions_karpenter.go#L209-L245","documentation":"Returned by buildKarpenterEC2NodeClass when tf.CloudTagsForInstanceGroup(ig) fails to compute cloud tags for the instance group. Tags feed the EC2NodeClass tags (after karpenterEC2NodeClassTags filtering), so tag computation failures block rendering.","triggerScenarios":"CloudTagsForInstanceGroup returns an error, e.g. cluster or instance-group metadata required for tag generation is unavailable or invalid (nil cluster, missing spec fields).","commonSituations":"Rendering templates with a TemplateFunctions whose cluster context is not fully initialized; instance group with invalid spec causing tag building to fail; custom hook-based tag configuration erroring.","solutions":["Check the wrapped error from CloudTagsForInstanceGroup for the failing field","Ensure the cluster spec and instance group spec are complete and validated","Verify the TemplateFunctions was built with the correct cluster context","Simplify custom tag configuration (cloudLabels/hooks) if it errors"],"exampleFix":"// before: invalid hook-derived label\ncloudLabels:\n  dynamic-tag: \"{{ .BadTemplate }}\"\n// after\ncloudLabels:\n  environment: production","handlingStrategy":"validation","validationCode":"// sanity-check tag sources before rendering\nif tf.ClusterName() == \"\" {\n\treturn errors.New(\"cluster name unset; cloud tags cannot be computed\")\n}\nif ig == nil || ig.Name == \"\" {\n\treturn errors.New(\"instance group missing; cloud tags cannot be computed\")\n}","typeGuard":null,"tryCatchPattern":"nc, err := tf.KarpenterEC2NodeClass(ig)\nif err != nil {\n\treturn fmt.Errorf(\"tag building for %q failed: %w\", ig.Name, err)\n}","preventionTips":["Initialize TemplateFunctions with a complete cluster context","Validate cluster and instance-group specs before rendering","Avoid custom label hooks that can fail during tag computation","Cover CloudTagsForInstanceGroup with unit tests"],"tags":["karpenter","tags","instance-group","kops"],"backgroundTag":"cloud-tags-computation-failed","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"}