kubernetes/kops · error

failed to convert provider ID number %q: %s

Error message

failed to convert provider ID number %q: %s

What it means

After stripping the 'digitalocean://' prefix, the remainder must be a numeric droplet ID. strconv.Atoi fails if it is non-numeric (or empty, though empty is caught earlier), producing this error with the offending value.

Source

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

		return nil, fmt.Errorf("provider ID %q is missing prefix %q", providerID, prefix)
	}

	instanceID := strings.TrimPrefix(providerID, prefix)
	if instanceID == "" {
		return nil, errors.New("provider ID number cannot be empty")
	}

	if i.cacheEnabled {
		if obj, exists, err := i.cache.GetByKey(instanceID); err != nil {
			klog.Warningf("Nodeidentity info cache lookup failure: %v", err)
		} else if exists {
			return obj.(*nodeidentity.Info), nil
		}
	}

	dropletID, err := strconv.Atoi(instanceID)
	if err != nil {
		return nil, fmt.Errorf("failed to convert provider ID number %q: %s", instanceID, err)
	}

	droplet, _, err := i.doClient.Droplets.Get(ctx, dropletID)
	if err != nil {
		return nil, fmt.Errorf("failed to retrieve droplet %d: %w", dropletID, err)
	}
	if droplet == nil {
		return nil, fmt.Errorf("droplet %d not found", dropletID)
	}
	if droplet.Status != "active" && droplet.Status != "new" {
		return nil, fmt.Errorf("droplet %d has unexpected status %q", dropletID, droplet.Status)
	}

	info := &nodeidentity.Info{
		InstanceID: instanceID,
		Labels:     labelsFromTags(droplet.Tags),
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Ensure the part after 'digitalocean://' is the numeric droplet ID (digits only)
  2. Look up the droplet's numeric ID in the DigitalOcean console or API (doctl compute droplet list) and fix the providerID
  3. Check the DO cloud controller manager version — it should set numeric droplet IDs
  4. Trim stray whitespace or URL fragments from the providerID value

Example fix

// before
"digitalocean://my-droplet-name"
// after
"digitalocean://3164444"
Defensive patterns

Strategy: validation

Validate before calling

id := strings.TrimPrefix(providerID, "digitalocean://")
if n, err := strconv.Atoi(id); err != nil || n <= 0 {
    return fmt.Errorf("droplet ID must be numeric, got %q", id)
}

Type guard

func isNumericDropletID(id string) bool {
    n, err := strconv.Atoi(id)
    return err == nil && n > 0
}

Try / catch

info, err := IdentifyNode(ctx, providerID)
if err != nil {
    if strings.Contains(err.Error(), "failed to convert provider ID number") {
        // surface a config error; fix providerID to a numeric droplet ID
    }
}

Prevention

When it happens

Trigger: providerID like 'digitalocean://abc' or 'digitalocean://droplet-123' passed to IdentifyNode — the instance portion contains non-digit characters.

Common situations: Custom tooling writing UUIDs or instance names instead of numeric droplet IDs into providerID; DO CCM version mismatch producing a different ID format; typos in manual cluster configuration.

Related errors


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