{"record":{"id":"0dea17cbdf6c0d8b","repo":"kubernetes/kops","slug":"error-finding-node-name-for-instance-v","errorCode":null,"errorMessage":"error finding node name for instance: %v","messagePattern":"error finding node name for instance: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete_instance.go","lineNumber":233,"sourceCode":"\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}\n\n\td := &instancegroups.RollingUpdateCluster{\n\t\tClientset:         clientSet,\n\t\tCluster:           cluster,\n\t\tMasterInterval:    0,\n\t\tNodeInterval:      0,\n\t\tBastionInterval:   0,\n\t\tInteractive:       false,\n\t\tForce:             true,\n\t\tCloud:             cloud,\n\t\tK8sClient:         k8sClient,","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete_instance.go#L215-L251","documentation":"After an instance is located in a cloud group, in API (non --cloudonly) mode kops requires the matching Kubernetes Node object to drain/cordon it. This error is returned when the cloud instance member was found but its Node field is nil — i.e. the cloud instance has no corresponding Node registered in the k8s API.","triggerScenarios":"`kops delete instance` (without --cloudonly) on an instance ID that exists in the cloud ASG but whose Node is absent from the cluster: the kubelet never registered, the Node was already deleted from the API, or the instance ID matches a cloud member only via ID and no Node.Name comparison succeeded.","commonSituations":"Instance booted but kubelet failed to start/join (bootstrap or networking problem); node was removed via `kubectl delete node` earlier but the EC2 instance still runs; long-stopped instance whose Node object was garbage-collected; instance group instances that are control-plane/masters never register as deletable nodes; API server reachable (nodes were listed successfully) so --cloudonly is the intended escape hatch.","solutions":["If you are sure the instance should be removed without k8s coordination, re-run with --cloudonly --yes.","Check whether the Node exists: `kubectl get nodes` and compare node names against the instance ID/private DNS.","If the Node object was deleted but the instance still runs, either recreate the Node object (restart kubelet) or just terminate the instance directly in the cloud console.","Investigate why the kubelet is not registering: check node bootstrap, IAM instance profile, and CNI/networking on the instance.","Confirm the instance belongs to this cluster (right VPC/account/cluster tags) — a foreign instance will never have a Node here."],"exampleFix":"// before\nkops delete instance --name mycluster.example.com i-0abc123\n// error: error finding node name for instance: i-0abc123\n// after (cloud-only deletion, skipping k8s API confirmation)\nkops delete instance --name mycluster.example.com i-0abc123 --cloudonly --yes","handlingStrategy":"validation","validationCode":"// before deleting in API mode, confirm the node is registered:\nnodes, err := getNodes(ctx, k8sClient, true)\nif err != nil {\n    return err\n}\nfound := false\nfor _, n := range nodes {\n    if n.Name == options.InstanceID || providerIDMatches(n, options.InstanceID) {\n        found = true\n        break\n    }\n}\nif !found {\n    return fmt.Errorf(\"instance %s has no registered Node; use --cloudonly or fix kubelet registration\", options.InstanceID)\n}","typeGuard":"func hasNode(m *cloudinstances.CloudInstance) bool { return m != nil && m.Node != nil }","tryCatchPattern":"if cloudMember.Node == nil {\n    if !options.CloudOnly {\n        fmt.Fprintf(os.Stderr, \"Instance %s has no k8s Node; retry with --cloudonly to delete without API confirmation\\n\", cloudMember.ID)\n        return fmt.Errorf(\"error finding node name for instance: %v\", cloudMember.ID)\n    }\n}","preventionTips":["Check `kubectl get nodes` shows the target node before deleting its instance.","Fix kubelet bootstrap/registration failures before rolling the instance.","Never `kubectl delete node` without also planning instance termination — it causes this mismatch.","Use --cloudonly deliberately when the Node is known to be gone."],"tags":["kubernetes","nodes","kops","cloud-instances"],"backgroundTag":"node-not-registered","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"}