kubernetes/kops · error

found multiple Instances with name: %s

Error message

found multiple Instances with name: %s

What it means

After DescribeInstances, Find() expects the task's name tag to match exactly one EC2 instance. If more than one instance matches the name, it cannot determine which one this task manages, so it fails rather than mutating the wrong instance. This is a uniqueness invariant of kops instance naming.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/instance.go:103

	response, err := cloud.EC2().DescribeInstances(ctx, request)
	if err != nil {
		return nil, fmt.Errorf("error listing instances: %v", err)
	}

	instances := []ec2types.Instance{}
	if response != nil {
		for _, reservation := range response.Reservations {
			instances = append(instances, reservation.Instances...)
		}
	}

	if len(instances) == 0 {
		return nil, nil
	}

	if len(instances) != 1 {
		return nil, fmt.Errorf("found multiple Instances with name: %s", *e.Name)
	}

	klog.V(2).Info("found existing instance")
	i := instances[0]

	if i.InstanceId == nil {
		return nil, fmt.Errorf("found instance, but InstanceId was nil")
	}

	actual := &Instance{
		ID:               i.InstanceId,
		PrivateIPAddress: i.PrivateIpAddress,
		InstanceType:     i.InstanceType,
		ImageID:          i.ImageId,
		Name:             findNameTag(i.Tags),
	}

	// Fetch instance UserData

View on GitHub (pinned to 4c8573c808)

Solutions

  1. List instances with the duplicated name tag (aws ec2 describe-instances --filters Name=tag:Name,Values=...) and terminate/retag the duplicate.
  2. Ensure instance groups have unique names in the cluster spec.
  3. If the duplicate was created by a stuck ASG, fix the ASG (delete stale instances).
  4. Re-run kops apply once the name is unique.

Example fix

# before: two instances tagged Name=nodes.cluster.k8s.local
aws ec2 terminate-instances --instance-ids i-0duplicate
# after: only one instance with that tag remains
Defensive patterns

Strategy: validation

Validate before calling

out, err := ec2.DescribeInstances(ctx, &ec2.DescribeInstancesInput{
  Filters: []ec2types.Filter{{Name: aws.String("tag:k8s.io/cluster/cluster.k8s.local"), Values: []string{"owned"}}},
})
// count instances per Name tag; fail if any tag maps to >1 instance

Type guard

func exactlyOne(instances []ec2types.Instance) (ec2types.Instance, bool) {
  if len(instances) != 1 { return ec2types.Instance{}, false }
  return instances[0], true
}

Try / catch

if err != nil && strings.Contains(err.Error(), "found multiple Instances with name") {
  klog.Errorf("duplicate instance name tags; dedupe before applying: %v", err)
}

Prevention

When it happens

Trigger: Two or more EC2 instances carry the same value for the filter kops uses (typically the Name tag combination for the instance group) in the same VPC/cluster.

Common situations: Manually launching a copy of an instance with the same tags; an autoscaling event leaving a duplicate; misconfigured instance group names colliding; snapshots/AMIs baked with tags being reused.

Related errors


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