{"record":{"id":"c5352623adba1819","repo":"kubernetes/kops","slug":"acceleratortype-must-not-be-empty","errorCode":null,"errorMessage":"acceleratorType must not be empty","messagePattern":"acceleratorType must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/accelerator_config.go","lineNumber":44,"sourceCode":"type AcceleratorConfig struct {\n\tAcceleratorCount int64  `json:\"acceleratorCount,omitempty\"`\n\tAcceleratorType  string `json:\"acceleratorType,omitempty\"`\n}\n\nvar (\n\t_ fi.CloudupHasDependencies = &AcceleratorConfig{}\n)\n\nfunc (a *AcceleratorConfig) GetDependencies(tasks map[string]fi.CloudupTask) []fi.CloudupTask {\n\treturn nil\n}\n\nfunc (_ *AcceleratorConfig) ShouldCreate(a, e, changes *AcceleratorConfig) (bool, error) {\n\tif e.AcceleratorCount < 0 {\n\t\treturn false, fmt.Errorf(\"acceleratorCount must be positive or 0\")\n\t}\n\tif e.AcceleratorType == \"\" {\n\t\treturn false, fmt.Errorf(\"acceleratorType must not be empty\")\n\t}\n\treturn true, nil\n}\n","sourceCodeStart":26,"sourceCodeEnd":48,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/accelerator_config.go#L26-L48","documentation":"AcceleratorConfig.ShouldCreate rejects an accelerator entry whose AcceleratorType is an empty string. GCE requires an explicit accelerator type (e.g. nvidia-tesla-t4) when attaching accelerators, so kOps fails fast instead of sending an incomplete Compute API request. Like the count check, this runs during the apply phase as a pre-creation guard.","triggerScenarios":"ShouldCreate runs with e.AcceleratorType == \"\" — an accelerators block in the cluster spec with acceleratorCount set but acceleratorType omitted or set to an empty/whitespace value.","commonSituations":"Users adding GPUs to an instance group but forgetting acceleratorType, copy-pasting a snippet and deleting the type line, or template generation emitting an empty acceleratorType when the variable is unset.","solutions":["Add a valid acceleratorType (e.g. nvidia-tesla-t4, nvidia-l4) to the accelerators block in the cluster/instance-group spec.","Verify the accelerator type is available in the target zone with `gcloud compute accelerator-types list --zones=<zone>`.","If no accelerator is needed, remove the accelerators entry instead of leaving the type empty.","Re-run `kops update cluster` after correcting the manifest."],"exampleFix":"// before\naccelerators:\n- acceleratorCount: 1\n  acceleratorType: \"\"\n// after\naccelerators:\n- acceleratorCount: 1\n  acceleratorType: nvidia-tesla-t4","handlingStrategy":"validation","validationCode":"if spec.AcceleratorType == \"\" && len(spec.Accelerators) > 0 {\n    return fmt.Errorf(\"acceleratorType must not be empty when accelerators are configured\")\n}","typeGuard":"func hasAcceleratorType(t string) bool { return strings.TrimSpace(t) != \"\" }","tryCatchPattern":null,"preventionTips":["Always pair acceleratorCount with a valid acceleratorType from `gcloud compute accelerator-types list`.","Use templating that fails on empty variables instead of interpolating empty strings.","Run `kops validate` / spec linting in CI to catch missing required fields before apply."],"tags":["gce","validation","gpu","config"],"backgroundTag":"missing-required-argument","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"}