kubernetes/kops · error

building node labels for instance group %q: %w

Error message

building node labels for instance group %q: %w

What it means

For each Hetzner node group, HCloudClusterConfig calls nodelabels.BuildNodeLabels(tf.Cluster, ig) to compute kubernetes node labels for the ServerGroup. If label building fails, the error wraps it with the instance group name.

Source

Thrown at upup/pkg/fi/cloudup/template_functions.go:1203

			continue
		}
		if ig.Spec.Autoscale != nil && !fi.ValueOf(ig.Spec.Autoscale) {
			continue
		}

		task, err := tf.Task("ServerGroup", ig.Name)
		if err != nil {
			return "", fmt.Errorf("finding server group task for instance group %q: %w", ig.Name, err)
		}

		serverGroup, ok := task.(*hetznertasks.ServerGroup)
		if !ok {
			return "", fmt.Errorf("server group task for instance group %q has unexpected type %T", ig.Name, task)
		}

		nodeLabels, err := nodelabels.BuildNodeLabels(tf.Cluster, ig)
		if err != nil {
			return "", fmt.Errorf("building node labels for instance group %q: %w", ig.Name, err)
		}

		userDataBytes, err := fi.ResourceAsBytes(serverGroup.UserData)
		if err != nil {
			return "", fmt.Errorf("reading user-data for instance group %q: %w", ig.Name, err)
		}

		var taints []corev1.Taint
		for _, taintSpec := range ig.Spec.Taints {
			parsed, err := util.ParseTaint(taintSpec)
			if err != nil {
				return "", fmt.Errorf("parsing taints for instance group %q: %w", ig.Name, err)
			}
			taints = append(taints, corev1.Taint{
				Key:    parsed["key"],
				Value:  parsed["value"],
				Effect: corev1.TaintEffect(parsed["effect"]),
			})

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the wrapped inner error for the exact label-building failure.
  2. Validate the instance group spec (names, roles, zones) for invalid values.
  3. Upgrade kOps so cluster and nodelabels code are from the same version.

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: validate cluster/ig fields BuildNodeLabels depends on
if cluster == nil || ig == nil || ig.ObjectMeta.Name == "" {
    return fmt.Errorf("cluster and named instance group required before building node labels")
}

Try / catch

// Go
nodeLabels, err := nodelabels.BuildNodeLabels(tf.Cluster, ig)
if err != nil {
    return "", fmt.Errorf("building node labels for instance group %q: %w", ig.Name, err)
}

Prevention

When it happens

Trigger: BuildNodeLabels returns an error for the given cluster/instance group — e.g. invalid instance group metadata/spec fields that label construction depends on, or unsupported cloud provider in the cluster spec for label building.

Common situations: Invalid characters/values in instance group spec affecting labels; cluster spec fields (roles, cloudProvider) inconsistent with what nodelabels expects; forked/older nodelabels package missing support for a new field.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/c5845bc459c8e747. Report an issue: GitHub.