kubernetes/kops · error

error listing instances: %v

Error message

error listing instances: %v

What it means

The Instance task's Find() discovers the existing EC2 instance matching the task by filters (name tag, etc.) using DescribeInstances; an SDK error there is wrapped as this message. Find is invoked by the fitask framework during apply and by reconciliation, so an AWS API failure here blocks the task's reconciliation.

Source

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

	var request *ec2.DescribeInstancesInput

	if fi.ValueOf(e.Shared) {
		var instanceIds []string
		instanceIds = append(instanceIds, aws.ToString(e.ID))
		request = &ec2.DescribeInstancesInput{
			InstanceIds: instanceIds,
		}
	} else {
		filters := cloud.BuildFilters(e.Name)
		filters = append(filters, awsup.NewEC2Filter("instance-state-name", "pending", "running", "stopping", "stopped"))
		request = &ec2.DescribeInstancesInput{
			Filters: filters,
		}
	}

	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")

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the wrapped AWS error code; for RequestLimitExceeded, retry after backoff.
  2. Validate AWS credentials (aws sts get-caller-identity) and that the cluster region is correct.
  3. Re-run kops update/apply once the AWS API is reachable.
  4. Reduce concurrent API usage if self-throttling in CI pipelines.

Example fix

// no code fix; typical remediation
// before: expired creds -> UnauthorizedOperation
// after: aws login / refresh credentials, then re-run kops update
Defensive patterns

Strategy: retry

Validate before calling

// before apply, confirm API reachability & identity
_, err := sts.GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{})
if err != nil { return fmt.Errorf("AWS API unreachable: %w", err) }

Type guard

var ae smithy.APIError
if errors.As(err, &ae) {
  retryable := ae.ErrorCode() == "RequestLimitExceeded" || ae.ErrorCode() == "ThrottlingException"
}

Try / catch

var ae smithy.APIError
if errors.As(err, &ae) && (ae.ErrorCode() == "RequestLimitExceeded" || ae.ErrorCode() == "ThrottlingException") {
  return retryWithBackoff(op, 5, time.Second)
}
return err

Prevention

When it happens

Trigger: cloud.EC2().DescribeInstances(ctx, request) returns any error: throttling (RequestLimitExceeded), invalid/unsupported filter, auth failure, or region/endpoint problems.

Common situations: Large clusters hitting EC2 describe rate limits; stale credentials or expired STS tokens; VPC/region misconfiguration in kops cluster spec; AWS outage.

Related errors


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