{"record":{"id":"8d138078e10ceebc","repo":"kubernetes/kops","slug":"listing-elb-targetgroups-w","errorCode":null,"errorMessage":"listing ELB TargetGroups: %w","messagePattern":"listing ELB TargetGroups: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/elbv2_targetgroups.go","lineNumber":66,"sourceCode":"\t\t}\n\t}\n\treturn \"\", false\n}\n\nfunc ListELBV2TargetGroups(ctx context.Context, cloud AWSCloud) ([]*TargetGroupInfo, error) {\n\tklog.V(2).Infof(\"Listing all target groups\")\n\n\trequest := &elbv2.DescribeTargetGroupsInput{}\n\t// ELBV2 DescribeTags has a limit of 20 names, so we set the page size here to 20 also\n\trequest.PageSize = aws.Int32(20)\n\n\tbyARN := make(map[string]*TargetGroupInfo)\n\n\tpaginator := elbv2.NewDescribeTargetGroupsPaginator(cloud.ELBV2(), request)\n\tfor paginator.HasMorePages() {\n\t\tpage, err := paginator.NextPage(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"listing ELB TargetGroups: %w\", err)\n\t\t}\n\t\tif len(page.TargetGroups) == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\ttagRequest := &elbv2.DescribeTagsInput{}\n\n\t\tfor _, tg := range page.TargetGroups {\n\t\t\tarn := aws.ToString(tg.TargetGroupArn)\n\t\t\tbyARN[arn] = &TargetGroupInfo{TargetGroup: tg, ARN: arn}\n\n\t\t\ttagRequest.ResourceArns = append(tagRequest.ResourceArns, aws.ToString(tg.TargetGroupArn))\n\t\t}\n\n\t\ttagResponse, err := cloud.ELBV2().DescribeTags(ctx, tagRequest)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"listing ELB TargetGroup tags: %w\", err)\n\t\t}","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/elbv2_targetgroups.go#L48-L84","documentation":"ListELBV2TargetGroups pages through DescribeTargetGroups using the AWS SDK paginator. Any error from the paginated API call is wrapped with this message, keeping the underlying SDK error for errors.Is/As inspection. It occurs before per-target-group tag fetching.","triggerScenarios":"DescribeTargetGroups API fails: bad/missing credentials, throttling, invalid region, network failure, or (when a name filter is used by findLatestTargetGroupByName) no/invalid parameters.","commonSituations":"Expired AWS sessions in long-running CI jobs; regional endpoint misconfiguration (e.g. cluster spec region mismatch); throttling when many reconciles list target groups concurrently.","solutions":["Unwrap the error with errors.Is/As to see the real SDK cause.","Verify AWS credentials and that the configured region matches the cluster's region.","Add retry/backoff for ThrottlingException and reduce concurrent listing.","Confirm IAM permissions include elasticloadbalancing:DescribeTargetGroups."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// preflight permission check via IAM policy simulator or dry-run call\n_, err := elbv2Client.DescribeTargetGroups(ctx, &elbv2.DescribeTargetGroupsInput{PageSize: aws.Int32(1)})","typeGuard":null,"tryCatchPattern":"tgs, err := cloud.ListELBV2TargetGroups()\nif err != nil {\n\tvar ae smithy.APIError\n\tif errors.As(err, &ae) && (ae.ErrorCode() == \"Throttling\" || ae.ErrorCode() == \"RequestLimitExceeded\") {\n\t\t// exponential backoff retry\n\t}\n\treturn err\n}","preventionTips":["Verify credentials/region before running kOps operations","Grant elasticloadbalancing:DescribeTargetGroups in IAM","Serialize or rate-limit concurrent reconciles that list target groups"],"tags":["aws","elbv2","target-group","api-error"],"backgroundTag":"aws-api-call-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}