{"record":{"id":"85b36d80039e1656","repo":"kubernetes/kops","slug":"reading-userdata-for-q-w","errorCode":null,"errorMessage":"reading userData for %q: %w","messagePattern":"reading userData for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions_karpenter.go","lineNumber":236,"sourceCode":"\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}\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}","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions_karpenter.go#L218-L254","documentation":"Returned by buildKarpenterEC2NodeClass when tf.managedFileContents(\"nodeupscript-\"+ig.Name) cannot read the bootstrap script managed file for the instance group. Karpenter nodes get nodeup via this userData, so a missing/unreadable managed file aborts EC2NodeClass construction.","triggerScenarios":"The managed file named \"nodeupscript-<ig.Name>\" does not exist in the build or its contents cannot be resolved when KarpenterEC2NodeClass renders — e.g. the nodeup script task was not created for that instance group.","commonSituations":"Instance group misnamed so the nodeupscript-<name> file was generated for a different key; bootstrap script generation skipped for Karpenter instance groups; ordering issues where userData is requested before file tasks are built.","solutions":["Verify a managed file task named \"nodeupscript-<ig.Name>\" is created for every Karpenter instance group","Check the wrapped error from managedFileContents for the exact missing key","Ensure kops config generation runs before Karpenter template rendering","Confirm instance group names contain no characters breaking the file key"],"exampleFix":"// before: ig named with mismatched key\nuserData, err := tf.managedFileContents(\"nodeupscript-worker\")\n// after: derive key from the actual instance group name\nuserData, err := tf.managedFileContents(\"nodeupscript-\" + ig.Name)","handlingStrategy":"validation","validationCode":"// ensure the nodeupscript managed file exists before rendering EC2NodeClass\nkey := \"nodeupscript-\" + ig.Name\nif !tf.HasManagedFile(key) {\n\treturn fmt.Errorf(\"managed file %q missing for instance group %q\", key, ig.Name)\n}","typeGuard":null,"tryCatchPattern":"nc, err := tf.KarpenterEC2NodeClass(ig)\nif err != nil {\n\treturn fmt.Errorf(\"userData for %q unavailable: %w\", ig.Name, err)\n}","preventionTips":["Generate nodeupscript-<name> tasks for every Karpenter instance group before rendering","Keep instance group naming consistent (no casing/space drift)","Verify build ordering: file tasks precede EC2NodeClass rendering","Add a CI check that all managed file references resolve"],"tags":["karpenter","userdata","managed-file","kops"],"backgroundTag":"missing-userdata-managed-file","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"}