kubernetes/kops · error

parsing taint %q for %q: %w

Error message

parsing taint %q for %q: %w

What it means

Each taint in ig.Spec.Taints is parsed with kopsutil.ParseTaint; when a taint string is malformed, buildKarpenterNodePool wraps the parse failure as 'parsing taint %q for %q: %w'. The NodePool manifest cannot be generated until the taint is fixed.

Source

Thrown at upup/pkg/fi/cloudup/template_functions_karpenter.go:427

	labels = karpenterNodePoolTemplateLabels(labels)

	template := karpenterNodeClaimTemplate{
		Spec: karpenterNodeClaimSpec{
			Requirements: tf.karpenterRequirements(ig),
			NodeClassRef: karpenterNodeClassRef{
				Group: karpenterAWSAPIGroup,
				Kind:  "EC2NodeClass",
				Name:  ig.Name,
			},
		},
	}
	if len(labels) != 0 {
		template.Metadata = &karpenterNodeClaimMetadata{Labels: labels}
	}
	for _, taintSpec := range ig.Spec.Taints {
		taint, err := kopsutil.ParseTaint(taintSpec)
		if err != nil {
			return nil, fmt.Errorf("parsing taint %q for %q: %w", taintSpec, ig.Name, err)
		}
		template.Spec.Taints = append(template.Spec.Taints, karpenterTaint{
			Key:    taint["key"],
			Value:  taint["value"],
			Effect: taint["effect"],
		})
	}

	spec := karpenterNodePoolSpec{
		Template: template,
	}
	if ig.Spec.MinSize != nil && *ig.Spec.MinSize > 0 {
		spec.Replicas = new(int64(*ig.Spec.MinSize))
	}
	if ig.Spec.MaxSize != nil {
		spec.Limits = &karpenterNodePoolLimits{Nodes: strconv.FormatInt(int64(*ig.Spec.MaxSize), 10)}
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Rewrite the taint in canonical form key=value:Effect, e.g. 'dedicated=special:NoSchedule'
  2. Ensure effect is one of NoSchedule, PreferNoSchedule, NoExecute
  3. Check for empty key/value or missing separators in every entry of the instance group's taints list
  4. Validate with `kops get ig <name> -oyaml` and re-run update

Example fix

// before
taints:
  - dedicated=true
// after
taints:
  - dedicated=true:NoSchedule
Defensive patterns

Strategy: validation

Validate before calling

// validate taints before update
for _, t := range ig.Spec.Taints {
	parts := strings.SplitN(t, ":", 2)
	if len(parts) != 2 || parts[0] == "" {
		return fmt.Errorf("taint %q must be key=value:Effect", t)
	}
	if !validEffects[parts[1]] {
		return fmt.Errorf("taint %q has invalid effect", t)
	}
}

Try / catch

if err != nil && strings.Contains(err.Error(), "parsing taint") {
	return fmt.Errorf("correct taint syntax in instance group: %w", err)
}

Prevention

When it happens

Trigger: InstanceGroup spec contains a taint not in key=value:effect format (e.g. missing colon, missing effect, empty key) while rendering a Karpenter NodePool.

Common situations: Hand-edited cluster spec with typos like 'dedicated=true' (no :effect), 'key=:NoSchedule', or stray whitespace; migrating taints from Kubernetes manifests with a different syntax.

Related errors


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