kubernetes/kops · error

failed to convert network ID %q to int: %w

Error message

failed to convert network ID %q to int: %w

What it means

During Hetzner load balancer creation, kOps parses the cluster network ID with strconv.ParseInt. This error wraps that parse failure, meaning the Network referenced by the load balancer task has an ID field that is not a plain decimal integer (or is empty). It indicates the network object attached to the cluster spec is malformed or was not resolved to a real Hetzner network.

Source

Thrown at upup/pkg/fi/cloudup/hetznertasks/loadbalancer.go:240

			return fi.RequiredField("Target")
		}
	}
	return nil
}

func (_ *LoadBalancer) RenderHetzner(t *hetzner.HetznerAPITarget, a, e, changes *LoadBalancer) error {
	ctx := context.TODO()
	actionClient := t.Cloud.ActionClient()
	client := t.Cloud.LoadBalancerClient()

	if a == nil {
		if e.Network == nil {
			return fmt.Errorf("failed to find network for loadbalancer %q", fi.ValueOf(e.Name))
		}

		networkID, err := strconv.ParseInt(fi.ValueOf(e.Network.ID), 10, 64)
		if err != nil {
			return fmt.Errorf("failed to convert network ID %q to int: %w", fi.ValueOf(e.Network.ID), err)
		}

		opts := hcloud.LoadBalancerCreateOpts{
			Name: fi.ValueOf(e.Name),
			LoadBalancerType: &hcloud.LoadBalancerType{
				Name: e.Type,
			},
			Algorithm: &hcloud.LoadBalancerAlgorithm{
				Type: hcloud.LoadBalancerAlgorithmTypeRoundRobin,
			},
			Location: &hcloud.Location{
				Name: e.Location,
			},
			Labels: e.Labels,
			Targets: []hcloud.LoadBalancerCreateOptsTarget{
				{
					Type: hcloud.LoadBalancerTargetTypeLabelSelector,
					LabelSelector: hcloud.LoadBalancerCreateOptsTargetLabelSelector{

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the cluster spec's network configuration and set the Hetzner network ID to a numeric decimal value (e.g. "1234567"), not a name.
  2. Ensure the hetznertasks Network task renders before the LoadBalancer task so the resolved ID is populated.
  3. Verify with `hcloud network list` that the network exists and copy its numeric ID exactly, without quotes/spaces.
  4. If the ID comes from code, confirm the field being passed is Network.ID and not Network.Name.

Example fix

// before
network:
  id: my-private-net
// after
network:
  id: "1234567"
Defensive patterns

Strategy: validation

Validate before calling

id := cluster.Spec.NetworkID
if n, err := strconv.ParseInt(id, 10, 64); err != nil || n <= 0 {
	return fmt.Errorf("hetzner network ID %q must be a positive numeric ID", id)
}

Prevention

When it happens

Trigger: RenderHetzner in upup/pkg/fi/cloudup/hetznertasks/loadbalancer.go:240 runs strconv.ParseInt(e.Network.ID, 10, 64) and it returns an error — e.g. Network.ID is an empty string, contains non-numeric characters, whitespace, or is a name instead of a numeric Hetzner network ID.

Common situations: Cluster config points at a network by name rather than numeric ID; the network task never ran/failed so the ID placeholder is empty; typos or copied values with quotes/spaces in the network ID field; YAML config where network id was set to a hostname or label.

Related errors


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