kubernetes/kops · error
error finding matching instance types: %w
Error message
error finding matching instance types: %w
What it means
instanceSelector.Filter(ctx, mutatedFilters) failed while matching the cluster's constraints (vCPU/memory ratio, flexible count, usage class, zones) against available EC2 instance types. The wrapped AWS or computation error is chained with %w. It occurs per instance group inside the creation loop.
Source
Thrown at cmd/kops/toolbox_instance-selector.go:297
filters := getFilters(commandline, region, zones)
mutatedFilters := filters
if commandline.Flags[instanceGroupCount] != nil || filters.Flexible != nil {
if filters.VCpusToMemoryRatio == nil {
defaultStartRatio := float64(2.0)
mutatedFilters.VCpusToMemoryRatio = &defaultStartRatio
}
}
newInstanceGroups := []*kops.InstanceGroup{}
for i := 0; i < igCount; i++ {
igNameForRun := options.InstanceGroupName
if igCount != 1 {
igNameForRun = fmt.Sprintf("%s%d", options.InstanceGroupName, i+1)
}
selectedInstanceTypes, err := instanceSelector.Filter(ctx, mutatedFilters)
if err != nil {
return fmt.Errorf("error finding matching instance types: %w", err)
}
if len(selectedInstanceTypes) == 0 {
return fmt.Errorf("no instance types were returned because the criteria specified was too narrow")
}
usageClass := *filters.UsageClass
ig := createInstanceGroup(igNameForRun, options.ClusterName, igSubnets)
ig = decorateWithInstanceGroupSpecs(ig, options)
ig, err = decorateWithMixedInstancesPolicy(ig, usageClass, selectedInstanceTypes)
if err != nil {
return err
}
if options.ClusterAutoscaler {
ig = decorateWithClusterAutoscalerLabels(ig, options.ClusterName)
}
ig, err = cloudup.PopulateInstanceGroupSpec(cluster, ig, cloud, channel)
if err != nil {
return errView on GitHub (pinned to 4c8573c808)
Solutions
- Read the wrapped (%w) cause to identify whether it is an AWS API error or a bad filter value.
- Relax the filter flags (e.g. drop --flexible or widen the vcpu:memory ratio).
- Verify the usage class flag is exactly 'spot' or 'regular'.
- Retry if the cause was transient AWS throttling.
Example fix
// before kops toolbox instance-selector --vcpus 0 --memory 0 ... // after kops toolbox instance-selector --vcpus 2 --memory 8 --flexible 2 ...
Defensive patterns
Strategy: validation
Validate before calling
func validateFilters(f selector.Filters) error {
if f.VCpusToMemoryRatio != nil && (*f.VCpusToMemoryRatio <= 0) {
return fmt.Errorf("vcpus-to-memory-ratio must be positive")
}
if f.UsageClass == nil || (*f.UsageClass != "spot" && *f.UsageClass != "regular") {
return fmt.Errorf("usageClass must be spot or regular")
}
return nil
} Try / catch
selected, err := instanceSelector.Filter(ctx, mutatedFilters)
if err != nil {
return fmt.Errorf("filtering failed (check flags & AWS API): %w", err)
} Prevention
- Validate numeric flags before passing them into Filters.
- Keep a default fallback filter set when custom flags fail.
- Log the full filter struct with the wrapped error.
When it happens
Trigger: Filter() returns an error for a given set of Filters — e.g. invalid vcpus-to-memory ratio values, an unsupported usage class, or an AWS API error while listing instance types during filtering.
Common situations: Passing nonsensical --vcpus-to-memory-ratio values; combining Spot usage class with constraints no spot capacity meets; filters computed from unusual subnet/zones inputs.
Related errors
- cannot select instance types from non-aws cluster
- error initializing instance selector: %v
- no instance types were returned because the criteria specifi
- DIGITALOCEAN_ACCESS_TOKEN is required
- the image for the hook exec action not set
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/0caa4009bc9b82ab.
Report an issue: GitHub.