kubernetes/kops · error

building node patch: %w

Error message

building node patch: %w

What it means

BootstrapControlPlaneNodeLabels marshals a strategic-merge patch containing the mandatory control-plane labels; this wraps json.Marshal failing. Since the payload is simple string maps, a marshal failure is unexpected and indicates a programming error in label construction.

Source

Thrown at channels/pkg/nodelabeler/labeler.go:70

	labels := nodelabels.BuildMandatoryControlPlaneLabels(nodeLabels)

	shouldPatch := false
	for k, v := range labels {
		if actual, found := node.Labels[k]; !found || actual != v {
			shouldPatch = true
			break
		}
	}
	if !shouldPatch {
		return nil
	}

	klog.V(2).Infof("patching node %q to add labels %v", nodeName, labels)
	patch, err := json.Marshal(&nodePatch{
		Metadata: &nodePatchMetadata{Labels: labels},
	})
	if err != nil {
		return fmt.Errorf("building node patch: %w", err)
	}

	klog.V(2).Infof("sending patch for node %q: %s", node.Name, patch)
	if _, err := client.CoreV1().Nodes().Patch(ctx, node.Name, types.StrategicMergePatchType, patch, metav1.PatchOptions{FieldManager: "kops-channels"}); err != nil {
		return fmt.Errorf("patching node %q: %w", node.Name, err)
	}
	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the wrapped marshal error and the labels built by BuildMandatoryControlPlaneLabels
  2. Report as a kops bug if label values contain data JSON cannot encode
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at channels/pkg/nodelabeler/labeler.go:70 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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