kubernetes/kops · error

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

Error message

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

What it means

The server ID extracted from the providerID could not be parsed as an integer, which getServer requires to call Hetzner's Server.GetByID. This wraps strconv.ParseInt's error with the offending string.

Source

Thrown at pkg/nodeidentity/hetzner/identify.go:145

		if err != nil {
			klog.Warningf("Failed to add node identity info to cache: %v", err)
		}
	}

	return info, nil
}

// stringKeyFunc is a string as cache key function
func stringKeyFunc(obj interface{}) (string, error) {
	key := obj.(*nodeidentity.Info).InstanceID
	return key, nil
}

// getServer queries Hetzner Cloud for the server with the specified ID, returning an error if not found
func (i *nodeIdentifier) getServer(id string) (*hcloud.Server, error) {
	serverID, err := strconv.ParseInt(id, 10, 64)
	if err != nil {
		return nil, fmt.Errorf("failed to convert server ID %q to int: %w", id, err)
	}
	server, _, err := i.client.Server.GetByID(context.TODO(), serverID)
	if err != nil || server == nil {
		return nil, fmt.Errorf("failed to get info for server %q: %w", id, err)
	}

	return server, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set providerID to the numeric server ID: hcloud://<id> (find via `hcloud server list`)
  2. Fix whatever component generates providerIDs (kubelet --provider-id or CCM) to use numeric IDs
  3. Delete the misconfigured Node and let it re-register with a correct providerID

Example fix

// before
providerID: hcloud://my-node-1
// after
providerID: hcloud://42981517
Defensive patterns

Strategy: validation

Validate before calling

if _, err := strconv.ParseInt(strings.TrimPrefix(node.Spec.ProviderID, "hcloud://"), 10, 64); err != nil { /* fix providerID first */ }

Type guard

func hcloudServerID(n *corev1.Node) (int64, bool) {
  id, ok := strings.CutPrefix(n.Spec.ProviderID, "hcloud://")
  if !ok { return 0, false }
  v, err := strconv.ParseInt(id, 10, 64)
  return v, err == nil
}

Try / catch

info, err := IdentifyNode(ctx, node)
if err != nil && strings.Contains(err.Error(), "failed to convert server ID") {
  // malformed providerID: fix Node spec and requeue
}

Prevention

When it happens

Trigger: strconv.ParseInt(id, 10, 64) fails because the portion after 'hcloud://' is non-numeric — e.g. 'hcloud://my-server-name' or 'hcloud://12345-foo' instead of a numeric Hetzner server ID.

Common situations: Hand-written providerID using server names instead of IDs; custom CCM emitting a different format; copy/paste of the server name from the Hetzner console rather than its numeric ID.

Related errors


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