{"record":{"id":"82c9030fa1f196ac","repo":"kubernetes/kops","slug":"error-node-usage-class-not-supported","errorCode":null,"errorMessage":"error node usage class not supported","messagePattern":"error node usage class not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/toolbox_instance-selector.go","lineNumber":539,"sourceCode":"\tig.Spec.MachineType = instanceSelections[0]\n\n\tswitch usageClass {\n\tcase ec2types.UsageClassTypeSpot:\n\t\tondemandBase := int64(0)\n\t\tondemandAboveBase := int64(0)\n\t\tspotAllocationStrategy := \"capacity-optimized\"\n\t\tig.Spec.MixedInstancesPolicy = &kops.MixedInstancesPolicySpec{\n\t\t\tInstances:              instanceSelections,\n\t\t\tOnDemandBase:           &ondemandBase,\n\t\t\tOnDemandAboveBase:      &ondemandAboveBase,\n\t\t\tSpotAllocationStrategy: &spotAllocationStrategy,\n\t\t}\n\tcase ec2types.UsageClassTypeOnDemand:\n\t\tig.Spec.MixedInstancesPolicy = &kops.MixedInstancesPolicySpec{\n\t\t\tInstances: instanceSelections,\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"error node usage class not supported\")\n\t}\n\n\treturn ig, nil\n}\n\n// decorateWithClusterAutoscalerLabels adds cluster-autoscaler discovery tags to the cloudlabels slice\nfunc decorateWithClusterAutoscalerLabels(instanceGroup *kops.InstanceGroup, clusterName string) *kops.InstanceGroup {\n\tig := instanceGroup\n\tif ig.Spec.CloudLabels == nil {\n\t\tig.Spec.CloudLabels = make(map[string]string)\n\t}\n\tig.Spec.CloudLabels[\"k8s.io/cluster-autoscaler/enabled\"] = \"1\"\n\tig.Spec.CloudLabels[\"k8s.io/cluster-autoscaler/\"+clusterName] = \"1\"\n\treturn ig\n}\n","sourceCodeStart":521,"sourceCodeEnd":555,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/toolbox_instance-selector.go#L521-L555","documentation":"Returned by decorateWithMixedInstancesPolicy in `kops toolbox instance-selector` when the requested EC2 usage class is neither \"spot\" nor \"on-demand\". The switch only handles ec2types.UsageClassTypeSpot and ec2types.UsageClassTypeOnDemand; any other value (including an empty/unset value) falls into the default branch. The AWS SDK enum was parsed from the --node-usage-class style flag, so an invalid or misspelled value surfaces here.","triggerScenarios":"Passing an unsupported value for the usage-class flag on `kops toolbox instance-selector`, e.g. \"reserved\", \"scheduled\", \"dedicated\", an empty string, or a typo like \"on demand\" that fails to map to ec2types.UsageClassTypeOnDemand.","commonSituations":"Confusing EC2 purchasing options (reserved/dedicated hosts) with the spot/on-demand usage class supported by mixed instances policies; typos or capitalization issues in the flag; scripts carrying an invalid default value from a template.","solutions":["Use `spot` for a spot mixed instances policy: --node-usage-class spot","Use `on-demand` (or `on-demand` exactly as accepted by the ec2types enum) for on-demand instances","Remove the flag to use the tool's default usage class if unsure","Check `kops toolbox instance-selector --help` for the exact accepted values and spelling"],"exampleFix":"// before\nkops toolbox instance-selector --name nodes --node-usage-class reserved\n\n// after\nkops toolbox instance-selector --name nodes --node-usage-class spot","handlingStrategy":"validation","validationCode":"switch strings.ToLower(usageClassFlag) {\ncase \"spot\", \"on-demand\", \"\":\n    // ok\ndefault:\n    return fmt.Errorf(\"unsupported usage class %q: use spot or on-demand\", usageClassFlag)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use values accepted by the ec2types.UsageClassType enum: spot / on-demand","Consult `kops toolbox instance-selector --help` before scripting the flag","Avoid mapping other EC2 purchase models (reserved, dedicated) onto this flag"],"tags":["kops","ec2","spot","cli","validation"],"backgroundTag":"invalid-usage-class","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"}