kubernetes/kops · error

failed to convert droplet ID to int: %s

Error message

failed to convert droplet ID to int: %s

What it means

DeleteInstance on DigitalOcean converts the CloudInstanceGroup member's string ID to an int with strconv.Atoi because the DO API takes a numeric droplet ID. If the ID is not a valid integer, kOps wraps the parse error with 'failed to convert droplet ID to int'. This indicates the instance record is corrupted or was constructed from a non-droplet entity.

Source

Thrown at upup/pkg/fi/cloudup/do/cloud.go:136

	return getCloudGroups(c, cluster, instancegroups, warnUnmatched, nodes)
}

// DeleteGroup is not implemented yet, is a func that needs to delete a DO instance group.
func (c *doCloudImplementation) DeleteGroup(g *cloudinstances.CloudInstanceGroup) error {
	klog.V(8).Info("digitalocean cloud provider DeleteGroup not implemented yet")
	return fmt.Errorf("digital ocean cloud provider does not support deleting cloud groups at this time")
}

// DeregisterInstance drains a cloud instance and loadbalancers.
func (c *doCloudImplementation) DeregisterInstance(i *cloudinstances.CloudInstance) error {
	klog.V(8).Info("DO DeregisterInstance not implemented")
	return nil
}

func (c *doCloudImplementation) DeleteInstance(i *cloudinstances.CloudInstance) error {
	dropletID, err := strconv.Atoi(i.ID)
	if err != nil {
		return fmt.Errorf("failed to convert droplet ID to int: %s", err)
	}

	_, _, err = c.Client.DropletActions.Shutdown(context.TODO(), dropletID)
	if err != nil {
		return fmt.Errorf("error stopping instance %d: %v", dropletID, err)
	}

	// Wait for 5 min to stop the instance
	for i := 0; i < 5; i++ {
		droplet, _, err := c.Client.Droplets.Get(context.TODO(), dropletID)
		if err != nil {
			return fmt.Errorf("error describing instance %d: %v", dropletID, err)
		}

		klog.V(8).Infof("stopping DO instance %q, current Status: %q", droplet, droplet.Status)

		if droplet.Status == "off" {
			break

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the instance in `kops get instancegroups` / cloud state; find the member whose ID is not numeric
  2. Run `kops update cluster --yes` (or `kops rolling-update cluster --cloud digitalocean --force`) to refresh cloud state from the DO API
  3. Remove the stale member from the InstanceGroup spec in the state store and re-run update
  4. Verify droplets exist in the DO project matching the cluster tag

Example fix

// before
# CloudInstance.ID = "" (stale member)
// after
kops update cluster --name cluster.example.com --yes   # rebuilds group from live droplets
# or edit spec to drop the stale member:
kops edit instancegroup nodes --name cluster.example.com
Defensive patterns

Strategy: validation

Validate before calling

if id, err := strconv.Atoi(i.ID); err != nil || id <= 0 {
    return fmt.Errorf("instance %q has invalid droplet ID; refresh cloud state first", i.ID)
}

Try / catch

dropletID, err := strconv.Atoi(i.ID)
if err != nil {
    return fmt.Errorf("skipping instance with non-numeric ID %q: %w", i.ID, err)
}

Prevention

When it happens

Trigger: Calling `kops delete instance` / rolling-update delete paths on a DO cluster where the CloudInstance.ID is empty, blank, or non-numeric (e.g. placeholder IDs from mis-parsed droplet lists or control-plane entries without real droplet backing).

Common situations: Stale kops state referencing deleted droplets; group membership built from nodes registered in k8s whose IDs are not droplet IDs; state-store corruption after manual droplet deletion.

Related errors


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