kubernetes/kops · error

Could not list flavors: %v

Error message

Could not list flavors: %v

What it means

defaultInstanceType lists Nova flavors with flavors.ListDetail (MinRAM 1024) and inspects them to pick a default instance type for an instance group. If the flavors list call fails, the error is wrapped as "Could not list flavors: %v". This blocks instance group creation/defaulting entirely.

Source

Thrown at upup/pkg/fi/cloudup/openstack/utils.go:64

	if s[i].VCPUs < s[j].VCPUs {
		return true
	}
	if s[i].VCPUs > s[j].VCPUs {
		return false
	}
	return s[i].RAM < s[j].RAM
}

func (c *openstackCloud) DefaultInstanceType(cluster *kops.Cluster, ig *kops.InstanceGroup) (string, error) {
	return defaultInstanceType(c, cluster, ig)
}

func defaultInstanceType(c OpenstackCloud, cluster *kops.Cluster, ig *kops.InstanceGroup) (string, error) {
	flavorPage, err := flavors.ListDetail(c.ComputeClient(), flavors.ListOpts{
		MinRAM: 1024,
	}).AllPages(context.TODO())
	if err != nil {
		return "", fmt.Errorf("Could not list flavors: %v", err)
	}
	var fList flavorList
	fList, err = flavors.ExtractFlavors(flavorPage)
	if err != nil {
		return "", fmt.Errorf("Could not extract flavors: %v", err)
	}
	sort.Sort(&fList)

	var candidates flavorList
	switch {
	case ig.Spec.Role.HasControlPlane():
		// Requirements based on awsCloudImplementation.DefaultInstanceType
		for _, flavor := range fList {
			if flavor.RAM >= 4096 && flavor.VCPUs >= 1 {
				candidates = append(candidates, flavor)
			}
		}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify `openstack flavor list` succeeds with the same credentials
  2. Check the wrapped error: 401 => re-auth, 403 => policy allows flavor listing, timeout => compute service/endpoint
  3. Set the instance type explicitly in the instance group spec (machineType) to skip flavor discovery
  4. Confirm the compute service endpoint in the Keystone catalog matches the region

Example fix

// before
spec:
  machineType: ""
// after: pin the flavor to avoid discovery failure
spec:
  machineType: m1.xlarge
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: confirm nova flavor listing works
if err := exec.Command("openstack", "flavor", "list", "--limit", "1").Run(); err != nil {
	log.Fatal("Nova compute API unreachable or flavors not listable")
}

Type guard

func isAuthErr(err error) bool {
	return err != nil && strings.Contains(err.Error(), "Authentication failed")
}

Try / catch

machineType, err := DefaultInstanceType(cloud, cluster, ig)
if err != nil {
	if strings.Contains(err.Error(), "Could not list flavors") {
		// fall back to an explicit machineType from the spec
		machineType = ig.Spec.MachineType
	}
	return err
}

Prevention

When it happens

Trigger: Nova compute API unreachable, auth/401 failure on the compute client, or the AllPages pagination call rejected by the server (bad ListOpts such as MinRAM).

Common situations: Compute service outage, wrong region/endpoint for the compute client, expired credentials, or an OpenStack deployment whose flavor listing requires admin privileges.

Related errors


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