{"record":{"id":"76f1f228c1024219","repo":"kubernetes/kops","slug":"can-only-delete-one-instance-group-at-a-time","errorCode":null,"errorMessage":"can only delete one instance group at a time","messagePattern":"can only delete one instance group at a time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete_instancegroup.go","lineNumber":82,"sourceCode":"\t\tAliases: []string{\"instancegroups\", \"ig\"},\n\t\tShort:   deleteInstanceGroupShort,\n\t\tLong:    deleteInstanceGroupLong,\n\t\tExample: deleteInstanceGroupExample,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\toptions.ClusterName = rootCommand.ClusterName(true)\n\n\t\t\tif options.ClusterName == \"\" {\n\t\t\t\treturn fmt.Errorf(\"--name is required\")\n\t\t\t}\n\n\t\t\tif len(args) == 0 {\n\t\t\t\treturn fmt.Errorf(\"must specify the name of the instance group to delete\")\n\t\t\t}\n\n\t\t\toptions.GroupName = args[0]\n\n\t\t\tif len(args) != 1 {\n\t\t\t\treturn fmt.Errorf(\"can only delete one instance group at a time\")\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t\tValidArgsFunction: completeInstanceGroup(f, nil, &[]string{kops.InstanceGroupRoleControlPlane.ToLowerString()}),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tctx := cmd.Context()\n\n\t\t\tif !options.Yes {\n\t\t\t\tmessage := fmt.Sprintf(\"Do you really want to delete instance group %q? This action cannot be undone.\", options.GroupName)\n\n\t\t\t\tc := &ui.ConfirmArgs{\n\t\t\t\t\tOut:     out,\n\t\t\t\t\tMessage: message,\n\t\t\t\t\tDefault: \"no\",\n\t\t\t\t\tRetries: 2,\n\t\t\t\t}\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete_instancegroup.go#L64-L100","documentation":"The Args validator accepts exactly one instance group per invocation. If more than one positional argument is passed, the command refuses with this error; each group must be deleted in a separate command run.","triggerScenarios":"Running `kops delete instancegroup --name <cluster> groupA groupB` or passing extra positional words (e.g. a stray filename from shell glob expansion).","commonSituations":"Assuming multi-arg support like `kubectl delete` resources; accidental glob expansion (*.yaml matching files); copy-pasting multiple group names from notes.","solutions":["Delete groups one at a time: run the command once per instance group.","Loop in shell: `for g in groupA groupB; do kops delete instancegroup --name \"$CLUSTER\" \"$g\"; done`.","Quote or disable globs so extra files aren't passed as arguments."],"exampleFix":"// before\n$ kops delete instancegroup --name prod.example.com workers spot-workers\nerror: can only delete one instance group at a time\n// after\n$ kops delete instancegroup --name prod.example.com workers\n$ kops delete instancegroup --name prod.example.com spot-workers","handlingStrategy":"validation","validationCode":"[ $# -eq 1 ] || { echo \"pass exactly one instance group\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Loop over groups instead of passing multiple arguments.","Quote globs (\"$@\", set -f) to avoid accidental extra positional args.","Read `kops delete instancegroup --help` to confirm single-argument arity."],"tags":["cli","kops","too-many-arguments","validation"],"backgroundTag":"too-many-arguments","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"}