{"record":{"id":"2832b37684c44b60","repo":"kubernetes/kops","slug":"keypair-s-task-not-found","errorCode":null,"errorMessage":"keypair/%s task not found","messagePattern":"keypair/(.+?) task not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/bootstrapscript.go","lineNumber":233,"sourceCode":"}\n\n// ResourceNodeUp generates and returns a nodeup (bootstrap) script from a\n// template file, substituting in specific env vars & cluster spec configuration\nfunc (b *BootstrapScriptBuilder) ResourceNodeUp(c *fi.CloudupModelBuilderContext, ig *kops.InstanceGroup) (fi.Resource, error) {\n\tkeypairNames := KeypairNamesForInstanceGroup(b.Cluster, ig)\n\n\tif ig.IsBastion() {\n\t\t// Bastions can have AdditionalUserData, but if there isn't any skip this part\n\t\tif len(ig.Spec.AdditionalUserData) == 0 {\n\t\t\treturn nil, nil\n\t\t}\n\t}\n\n\tkeypairTasks := map[string]*fitasks.Keypair{}\n\tfor _, keypair := range keypairNames {\n\t\tcaTaskObject, found := c.Tasks[\"Keypair/\"+keypair]\n\t\tif !found {\n\t\t\treturn nil, fmt.Errorf(\"keypair/%s task not found\", keypair)\n\t\t}\n\t\tkeypairTasks[keypair] = caTaskObject.(*fitasks.Keypair)\n\t}\n\n\ttask := &BootstrapScript{\n\t\tName:      ig.Name,\n\t\tLifecycle: b.Lifecycle,\n\t\tcluster:   b.Cluster,\n\t\tig:        ig,\n\t\tbuilder:   b,\n\t\tcaTasks:   keypairTasks,\n\t}\n\ttask.resource.Task = task\n\ttask.nodeupConfig.Task = task\n\ttask.nodeupScript.Task = task\n\tc.AddTask(task)\n\n\tc.AddTask(&fitasks.ManagedFile{","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/bootstrapscript.go#L215-L251","documentation":"ResourceNodeUp resolves the Keypair tasks required by the instance group (from keypairNames, e.g. the cluster CA) by looking up task keys \"Keypair/<name>\" in the fi.CloudupContext task map. If a required keypair task was never created by earlier model builders, it returns this error.","triggerScenarios":"Building nodeup bootstrap resources (via `kops update cluster`, elastigroup/launch-template/VMSS builders, or tests) when the target's task map lacks a Keypair task for one of the required CA names.","commonSituations":"Custom/patched model builders that skip Keypair task creation; cluster specs referencing an unusual CA name; running builders out of order in custom code; test harnesses that did not add Keypair tasks.","solutions":["Ensure the standard model builders run before bootstrap script building so Keypair tasks are registered (build CA task for each keypairName).","Check keypairNames derivation and the cluster spec for an unexpected CA/keyset name causing the lookup mismatch.","In tests or custom builders, add the missing fitasks.Keypair to c.Tasks under the exact key \"Keypair/<name>\"."],"exampleFix":"// before (custom builder omits CA task)\n// no Keypair task added\n// after\ncaTask := &fitasks.Keypair{Name: fi.PtrTo(\"kubernetes-ca\")}\nc.AddTask(\"Keypair/kubernetes-ca\", caTask)","handlingStrategy":"type-guard","validationCode":"if obj, found := c.Tasks[\"Keypair/\"+caName]; !found {\n  return fmt.Errorf(\"builder precondition failed: %s keypair task missing\", caName)\n}","typeGuard":"func keypairTask(c *fi.CloudupContext, name string) (*fitasks.Keypair, bool) {\n  obj, found := c.Tasks[\"Keypair/\"+name]\n  if !found {\n    return nil, false\n  }\n  kp, ok := obj.(*fitasks.Keypair)\n  return kp, ok\n}","tryCatchPattern":null,"preventionTips":["Always run the standard CA/keypair model builders before bootstrap script builders.","In tests, register all required Keypair tasks in the context map.","Use exact task key format \"Keypair/<name>\" when adding tasks."],"tags":["keypair","ca","nodeup","tasks"],"backgroundTag":"keypair-task-not-found","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"}