{"record":{"id":"b2c581f3fab806cd","repo":"kubernetes/kops","slug":"finding-server-group-task-for-instance-group-q","errorCode":null,"errorMessage":"finding server group task for instance group %q: %w","messagePattern":"finding server group task for instance group %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions.go","lineNumber":1193,"sourceCode":"\ttype hcloudClusterConfig struct {\n\t\tNodeConfigs map[string]hcloudNodeConfig `json:\"nodeConfigs,omitempty\"`\n\t}\n\n\tconfig := &hcloudClusterConfig{\n\t\tNodeConfigs: map[string]hcloudNodeConfig{},\n\t}\n\n\tfor _, ig := range tf.KopsModelContext.InstanceGroups {\n\t\tif !ig.Spec.Role.HasNode() {\n\t\t\tcontinue\n\t\t}\n\t\tif ig.Spec.Autoscale != nil && !fi.ValueOf(ig.Spec.Autoscale) {\n\t\t\tcontinue\n\t\t}\n\n\t\ttask, err := tf.Task(\"ServerGroup\", ig.Name)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"finding server group task for instance group %q: %w\", ig.Name, err)\n\t\t}\n\n\t\tserverGroup, ok := task.(*hetznertasks.ServerGroup)\n\t\tif !ok {\n\t\t\treturn \"\", fmt.Errorf(\"server group task for instance group %q has unexpected type %T\", ig.Name, task)\n\t\t}\n\n\t\tnodeLabels, err := nodelabels.BuildNodeLabels(tf.Cluster, ig)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"building node labels for instance group %q: %w\", ig.Name, err)\n\t\t}\n\n\t\tuserDataBytes, err := fi.ResourceAsBytes(serverGroup.UserData)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"reading user-data for instance group %q: %w\", ig.Name, err)\n\t\t}\n\n\t\tvar taints []corev1.Taint","sourceCodeStart":1175,"sourceCodeEnd":1211,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions.go#L1175-L1211","documentation":"HCloudClusterConfig builds the Hetzner cloud-controller/cluster config per node instance group. It looks up the corresponding ServerGroup task created by the Hetzner model via tf.Task(\"ServerGroup\", ig.Name). If that task lookup fails (task not registered for this instance group), the error wraps the underlying cause.","triggerScenarios":"Generating Hetzner cluster config for an instance group that has no ServerGroup task in the context — e.g. calling the template function for a control-plane/master group, or for a group the Hetzner model did not create a ServerGroup for (autoscale disabled path, wrong ig list).","commonSituations":"Custom templates omitting the ServerGroup task for a group; invoking HCloudClusterConfig for groups it was not designed for (control-plane groups); template execution order issues where tasks were not yet registered.","solutions":["Ensure the Hetzner model creates a ServerGroup task for every instance group passed to HCloudClusterConfig (check the hetzner model templates).","Skip or filter instance groups (e.g. control-plane) that should not get a ServerGroup.","Upgrade kOps if a recent provider/model change broke task registration."],"exampleFix":"// before\nfor _, ig := range masterAndNodeGroups { config += hcloudClusterConfig(tf, ig) }\n// after\nfor _, ig := range nodeGroups { config += hcloudClusterConfig(tf, ig) }","handlingStrategy":"type-guard","validationCode":"// Go: only call HCloudClusterConfig for groups the Hetzner model provisions\ntask, err := tf.Task(\"ServerGroup\", ig.Name)\nif err != nil {\n    klog.V(2).Infof(\"skipping ig %q: no ServerGroup task (%v)\", ig.Name, err)\n    continue\n}","typeGuard":"// Go\nsg, ok := task.(*hetznertasks.ServerGroup)\nif !ok {\n    return \"\", fmt.Errorf(\"task %q is %T, want *hetznertasks.ServerGroup\", ig.Name, task)\n}\n_ = sg","tryCatchPattern":null,"preventionTips":["Use stock Hetzner model templates","Keep kOps binary and templates versions in sync","Filter to node instance groups when building cloud config"],"tags":["hetzner","template-function","task-lookup"],"backgroundTag":"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"}