{"record":{"id":"ca8c1e8f32b80884","repo":"kubernetes/kops","slug":"could-not-find-instance-v","errorCode":null,"errorMessage":"could not find instance %v","messagePattern":"could not find instance (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete_instance.go","lineNumber":222,"sourceCode":"\tvar instanceGroups []*kopsapi.InstanceGroup\n\tfor i := range list.Items {\n\t\tinstanceGroups = append(instanceGroups, &list.Items[i])\n\t}\n\n\tcloud, err := cloudup.BuildCloud(cluster)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgroups, err := cloud.GetCloudGroups(cluster, instanceGroups, false, nodes)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcloudMember := findDeletionNode(groups, options)\n\n\tif cloudMember == nil {\n\t\treturn fmt.Errorf(\"could not find instance %v\", options.InstanceID)\n\t}\n\n\tif options.CloudOnly {\n\t\tfmt.Fprintf(out, \"Instance %v found for deletion\\n\", cloudMember.ID)\n\t} else {\n\t\tif cloudMember.Node != nil {\n\t\t\tfmt.Fprintf(out, \"Instance %v (%v) found for deletion\\n\", cloudMember.ID, cloudMember.Node.Name)\n\t\t} else {\n\t\t\tfmt.Fprintf(os.Stderr, \"Instance is not a member of the cluster\\n\")\n\t\t\tfmt.Fprintf(os.Stderr, \"Use --cloudonly to do a deletion without confirming progress with the k8s API\\n\\n\")\n\t\t\treturn fmt.Errorf(\"error finding node name for instance: %v\", cloudMember.ID)\n\t\t}\n\t}\n\n\tif !options.Yes {\n\t\tfmt.Fprintf(out, \"\\nMust specify --yes to delete instance\\n\")\n\t\treturn nil\n\t}","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete_instance.go#L204-L240","documentation":"RunDeleteInstance returns this when findDeletionNode scans all cloud instance groups (ASGs/instance groups of the cluster) and no CloudInstance member matches options.InstanceID. The instance ID given on the command line does not correspond to any instance currently registered in the cluster's cloud groups.","triggerScenarios":"`kops delete instance <cluster> --instance-id i-0abc123...` (or a node name, when not --cloudonly) where the ID matches neither a cloudMember.ID nor — in API mode — any Node's name, i.e. findDeletionNode returns nil.","commonSituations":"Typo or truncated instance ID; instance was already terminated; querying the wrong cluster (--name) or wrong cloud provider account/region (KOPS_STATE_STORE/cloud config); passing a node name while using --cloudonly (node-name matching is disabled in cloud-only mode); autoscaler already replaced the instance so the ID no longer exists in any group.","solutions":["List current instances/nodes with `kops get instances` (or cloud console / `kubectl get nodes`) and confirm the exact instance ID.","Verify you targeted the right cluster: add `--name <cluster>` and check KOPS_STATE_STORE points at the correct state store.","If the instance is already gone, nothing to delete — verify with the cloud provider CLI (e.g. `aws ec2 describe-instances --instance-ids ...`).","If you have only the node name, drop --cloudonly so deleteNodeMatch can also compare cloudMember.Node.Name.","Re-run `kops update cluster` / refresh cloud groups if the instance group spec is stale."],"exampleFix":"// before\nkops delete instance --name mycluster.example.com i-0123xyz\n// error: could not find instance i-0123xyz\n// after\nkops get instances --name mycluster.example.com   # find correct ID\nkops delete instance --name mycluster.example.com i-0abc123def456 --yes","handlingStrategy":"validation","validationCode":"// before running the command, confirm the instance exists in this cluster's groups:\nclientSet, _ := f.KopsClient()\ncluster, _ := GetCluster(ctx, f, options.ClusterName)\nigs, _ := clientSet.InstanceGroupsFor(cluster).List(ctx, metav1.ListOptions{})\nif len(igs.Items) == 0 {\n    return fmt.Errorf(\"no instance groups for cluster %q; check --name and KOPS_STATE_STORE\", options.ClusterName)\n}\n// verify the ID with the cloud CLI, e.g.:\n// aws ec2 describe-instances --instance-ids i-0abc123 --filters Name=tag:kubernetes.io/cluster/<cluster>,Values=owned","typeGuard":null,"tryCatchPattern":"cloudMember := findDeletionNode(groups, options)\nif cloudMember == nil {\n    return fmt.Errorf(\"could not find instance %q in cluster %q; run 'kops get instances' to list valid IDs\", options.InstanceID, options.ClusterName)\n}","preventionTips":["Copy instance IDs from `kops get instances` output, never from memory.","Always pass --name <cluster> explicitly to avoid acting on the wrong cluster.","Remember node-name matching is disabled in --cloudonly mode; use the cloud instance ID there.","Check the cloud console before deleting to confirm the instance is not already terminated or replaced by the autoscaler."],"tags":["kops","instance-groups","cli","identifier-not-found"],"backgroundTag":"resource-not-found","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"}