{"record":{"id":"b266d33419db94e2","repo":"kubernetes/kops","slug":"can-only-delete-one-instance-at-a-time","errorCode":null,"errorMessage":"can only delete one instance at a time","messagePattern":"can only delete one instance at a time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete_instance.go","lineNumber":133,"sourceCode":"\n\tcmd := &cobra.Command{\n\t\tUse:     \"instance INSTANCE|NODE\",\n\t\tShort:   deleteInstanceShort,\n\t\tLong:    deleteInstanceLong,\n\t\tExample: deleteInstanceExample,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\toptions.ClusterName = rootCommand.ClusterName(true)\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 ID of instance or name of node to delete\")\n\t\t\t}\n\t\t\toptions.InstanceID = args[0]\n\n\t\t\tif len(args) != 1 {\n\t\t\t\treturn fmt.Errorf(\"can only delete one instance at a time\")\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t\tValidArgsFunction: completeInstanceOrNode(f, &options),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn RunDeleteInstance(cmd.Context(), f, out, &options)\n\t\t},\n\t}\n\n\tcmd.Flags().BoolVar(&options.CloudOnly, \"cloudonly\", options.CloudOnly, \"Perform deletion update without confirming progress with Kubernetes\")\n\tcmd.Flags().BoolVar(&options.Surge, \"surge\", options.Surge, \"Surge by detaching the node from the ASG before deletion\")\n\n\tcmd.Flags().DurationVar(&options.ValidationTimeout, \"validation-timeout\", options.ValidationTimeout, \"Maximum time to wait for a cluster to validate\")\n\tcmd.Flags().Int32Var(&options.ValidateCount, \"validate-count\", options.ValidateCount, \"Number of times that a cluster needs to be validated after single node update\")\n\tcmd.Flags().DurationVar(&options.PostDrainDelay, \"post-drain-delay\", options.PostDrainDelay, \"Time to wait after draining each node\")\n\n\tcmd.Flags().BoolVar(&options.FailOnDrainError, \"fail-on-drain-error\", true, \"Fail if draining a node fails\")","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete_instance.go#L115-L151","documentation":"Argument validation in `kops delete instance`: the command accepts exactly one positional argument (an instance ID or node name), and this guard fires when more than one is given. Batch deletion is not supported through this command.","triggerScenarios":"Running `kops delete instance i-123 i-456` or passing extra tokens (e.g. an unquoted node name with spaces or stray flags consumed as args).","commonSituations":"Scripts looping lists without quoting; users assuming batch deletion is supported.","solutions":["Delete one instance per command invocation.","Loop in shell: `for id in $IDS; do kops delete instance \"$id\" --name ...; done`.","Quote node names containing spaces so they collapse to a single argument."],"exampleFix":"// before\nkops delete instance i-0abc i-0def --name cluster.example.com\n// after\nfor id in i-0abc i-0def; do kops delete instance \"$id\" --name cluster.example.com; done","handlingStrategy":"validation","validationCode":"ids := strings.Fields(idList)\nif len(ids) != 1 {\n    return fmt.Errorf(\"kops delete instance accepts exactly one ID; got %d\", len(ids))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote arguments to avoid word-splitting adding extra args.","Loop over IDs instead of passing multiple positionals.","Validate argument count in wrapper scripts."],"tags":["cli","validation","argument-count"],"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-12T12:17:11.808Z"}