kubernetes/kops · error

found %d TargetGroups with ID %q, expected 1

Error message

found %d TargetGroups with ID %q, expected 1

What it means

DescribeTargetGroups by ARN returned more than one target group, which the AWS API should never do; treated as an invariant violation rather than a user-fixable condition.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/targetgroup.go:190

	request.TargetGroupArns = []string{aws.ToString(e.ARN)}

	var targetGroups []elbv2types.TargetGroup
	paginator := elbv2.NewDescribeTargetGroupsPaginator(cloud.ELBV2(), request)
	for paginator.HasMorePages() {
		page, err := paginator.NextPage(ctx)
		if err != nil {
			var nfe *elbv2types.TargetGroupNotFoundException
			if errors.As(err, &nfe) {
				if !fi.ValueOf(e.Shared) {
					return nil, nil
				}
			}
			return nil, fmt.Errorf("error describing targetgroup %s: %w", *e.ARN, err)
		}
		targetGroups = append(targetGroups, page.TargetGroups...)
	}
	if len(targetGroups) > 1 {
		return nil, fmt.Errorf("found %d TargetGroups with ID %q, expected 1", len(targetGroups), fi.ValueOf(e.Name))
	} else if len(targetGroups) == 0 {
		return nil, nil
	}
	tg := targetGroups[0]

	tagResponse, err := cloud.ELBV2().DescribeTags(ctx, &elbv2.DescribeTagsInput{
		ResourceArns: []string{aws.ToString(tg.TargetGroupArn)},
	})
	if err != nil {
		return nil, err
	}

	info := &awsup.TargetGroupInfo{
		TargetGroup: tg,
		ARN:         aws.ToString(tg.TargetGroupArn),
	}

	for _, t := range tagResponse.TagDescriptions {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Retry the apply — this indicates an anomalous AWS API response
  2. Open a kOps GitHub issue if it reproduces
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/awstasks/targetgroup.go:190 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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