{"record":{"id":"fb07628b7d772d1a","repo":"kubernetes/kops","slug":"error-building-node-labels-w","errorCode":null,"errorMessage":"error building node labels: %w","messagePattern":"error building node labels: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/context.go","lineNumber":179,"sourceCode":"\tfor k, v := range ig.Spec.CloudLabels {\n\t\tlabels[k] = v\n\t}\n\n\tif b.Cluster.Spec.CloudProvider.AWS != nil {\n\t\t// Apply NTH Labels\n\t\tnth := b.Cluster.Spec.CloudProvider.AWS.NodeTerminationHandler\n\t\tif nth.IsQueueMode() {\n\t\t\tk := fi.ValueOf(nth.ManagedASGTag)\n\t\t\tif _, ok := labels[k]; !ok && k != \"\" {\n\t\t\t\tlabels[k] = \"\"\n\t\t\t}\n\t\t}\n\t}\n\n\t// Apply labels for cluster autoscaler node labels\n\tnodeLabels, err := nodelabels.BuildNodeLabels(b.Cluster, ig)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error building node labels: %w\", err)\n\t}\n\tfor k, v := range nodeLabels {\n\t\tswitch b.Cluster.GetCloudProvider() {\n\t\tcase kops.CloudProviderHetzner:\n\t\t\tlabels[hetzner.TagKubernetesNodeLabelPrefix+k] = v\n\t\tcase kops.CloudProviderGCE:\n\t\t\t// TODO: Do nothing for now while we figure out how to address GCE label length limit of 63\n\t\tcase kops.CloudProviderLinode:\n\t\t\t// Akamai (Linode) Cloud tags have a 50 character limit\n\t\t\t// Only store the critical kops.k8s.io/instancegroup label\n\t\t\t// Role labels will be derived from the instance role tag by the identifier\n\t\t\tif k == linode.TagKubernetesInstanceGroup {\n\t\t\t\tlabels[k] = v\n\t\t\t}\n\t\tdefault:\n\t\t\tlabels[nodeidentityaws.ClusterAutoscalerNodeTemplateLabel+k] = v\n\t\t}\n\t}","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/context.go#L161-L197","documentation":"This wrapper error is raised while building node label configuration (pkg/model/context.go:179) after nodelabels.BuildNodeLabels fails. BuildNodeLabels computes the well-known labels (kops.k8s.io/instancegroup, cluster-autoscaler kops.k8s.io/node-labels, etc.) from the cluster and instance group specs; an invalid spec value (e.g. malformed autoscaler node labels) bubbles up here wrapped with 'error building node labels'.","triggerScenarios":"Building a node model for an instance group whose spec contains invalid well-known labels — e.g. instanceGroup.spec.wellKnownLabels with malformed cluster-autoscaler node labels, or a spec the label builder cannot reconcile.","commonSituations":"Adding cluster-autoscaler node labels via 'kops edit ig' with wrong syntax, version upgrades introducing new label requirements, or templated manifests with malformed label maps.","solutions":["Inspect the wrapped inner error (%w) in the full log message to see the underlying cause","Run 'kops edit ig <name>' and fix spec.wellKnownLabels / node-label entries to be valid 'key=value' pairs","Validate keys against Kubernetes label key/value constraints (63 chars, alphanumeric with -_.)","Re-run 'kops update cluster' after correcting the spec"],"exampleFix":"// before (instance group)\nwellKnownLabels: \"kops.k8s.io/instancegroup=nodes, node-labels=\"\n// after\nwellKnownLabels: \"kops.k8s.io/instancegroup=nodes,kops.k8s.io/scale-to-zero=true\"","handlingStrategy":"try-catch","validationCode":"// Validate label entries are key=value and key/value charset-valid before building\nfor _, kv := range strings.Split(ig.Spec.WellKnownLabels, \",\") {\n\tparts := strings.SplitN(strings.TrimSpace(kv), \"=\", 2)\n\tif len(parts) != 2 || parts[0] == \"\" || parts[1] == \"\" {\n\t\treturn fmt.Errorf(\"malformed label %q in IG %q\", kv, ig.Name)\n\t}\n}","typeGuard":null,"tryCatchPattern":"nodeLabels, err := nodelabels.BuildNodeLabels(cluster, ig)\nif err != nil {\n\treturn fmt.Errorf(\"error building node labels: %w\", err) // inspect wrapped cause in logs\n}","preventionTips":["Use 'kops edit ig' instead of hand-writing wellKnownLabels","Keep label keys within K8s constraints (<=63 chars, [-A-Za-z0-9_.])","Check the wrapped inner error (%w chain) to find the real offending field","Pin the kOps version when generating specs programmatically"],"tags":["kops","node-labels","instance-group","validation"],"backgroundTag":"node-label-build-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"}