kubernetes/kops · error

unexpected resource type: %s

Error message

unexpected resource type: %s

What it means

A fall-through switch guard: buildCloudInstanceGroupFromResource receives a resource whose Type is neither ResourceTypeInstanceGroup nor ResourceTypeLaunchSpec (or whose Obj fails the type assertion), so it cannot build a cloud instance group for it.

Source

Thrown at pkg/resources/spotinst/resources.go:272

	}

	switch ResourceType(resource.Type) {
	case ResourceTypeInstanceGroup:
		{
			if group, ok := resource.Obj.(InstanceGroup); ok {
				return buildCloudInstanceGroupFromInstanceGroup(cloud, ig, group, nodeMap)
			}
		}

	case ResourceTypeLaunchSpec:
		{
			if spec, ok := resource.Obj.(LaunchSpec); ok {
				return buildCloudInstanceGroupFromLaunchSpec(cloud, ig, spec, nodeMap)
			}
		}
	}

	return nil, fmt.Errorf("unexpected resource type: %s", resource.Type)
}

func buildCloudInstanceGroupFromInstanceGroup(cloud Cloud, ig *kops.InstanceGroup, group InstanceGroup,
	nodeMap map[string]*v1.Node) (*cloudinstances.CloudInstanceGroup, error,
) {
	instanceGroup := &cloudinstances.CloudInstanceGroup{
		HumanName:     group.Name(),
		InstanceGroup: ig,
		MinSize:       group.MinSize(),
		TargetSize:    group.MinSize(), // TODO: Retrieve the target size from the cloud provider
		MaxSize:       group.MaxSize(),
		Raw:           group,
	}

	var svc InstanceGroupService
	switch group.Type() {
	case InstanceGroupElastigroup:
		svc = cloud.Elastigroup()

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check how the resource tracker was created — only instance group and launch spec types are supported
  2. Report a kOps bug if a new spotinst resource type was added without updating this switch
  3. Re-run discovery after fixing the resource type
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at pkg/resources/spotinst/resources.go:272 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/831b516a73a5f9a0. Report an issue: GitHub.