{"record":{"id":"211b906000a33e53","repo":"kubernetes/kops","slug":"node-name-not-set","errorCode":null,"errorMessage":"node name not set","messagePattern":"node name not set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/instancegroups/instancegroups.go","lineNumber":680,"sourceCode":"\t\t}\n\t\treturn fmt.Errorf(\"error deleting instance %q: %v\", id, err)\n\t}\n\n\treturn nil\n}\n\n// drainNode drains a K8s node.\nfunc (c *RollingUpdateCluster) drainNode(ctx context.Context, u *cloudinstances.CloudInstance) error {\n\tif c.K8sClient == nil {\n\t\treturn fmt.Errorf(\"K8sClient not set\")\n\t}\n\n\tif u.Node == nil {\n\t\treturn fmt.Errorf(\"node not set\")\n\t}\n\n\tif u.Node.Name == \"\" {\n\t\treturn fmt.Errorf(\"node name not set\")\n\t}\n\n\thelper := &drain.Helper{\n\t\tCtx:                 ctx,\n\t\tClient:              c.K8sClient,\n\t\tForce:               true,\n\t\tGracePeriodSeconds:  -1,\n\t\tIgnoreAllDaemonSets: true,\n\t\tOut:                 os.Stdout,\n\t\tErrOut:              os.Stderr,\n\t\tTimeout:             c.DrainTimeout,\n\n\t\t// The zero value would retry evictions without any delay\n\t\tEvictErrorRetryDelay: 5 * time.Second,\n\n\t\t// We want to proceed even when pods are using emptyDir volumes\n\t\tDeleteEmptyDirData: true,\n\t}","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/instancegroups/instancegroups.go#L662-L698","documentation":"drainNode in kOps' rolling-update machinery validates that the CloudInstance being drained has an associated k8s Node object with a non-empty Name before invoking the generic drain.Helper. The 'node not set'/'node name not set' errors are thrown when the CloudInstance wrapper lacks a populated Kubernetes Node reference, which later drain/cordon steps require to address the node via the API.","triggerScenarios":"drainTerminateAndWait passes a CloudInstance whose Node field is nil, or whose Node exists but has an empty metadata.name — typically when an instance was listed in the cloud but its corresponding Node object was never registered (or was already deleted) in the cluster.","commonSituations":"Running `kops rolling-update cluster` while an instance was terminated out-of-band (cloud console/autoscaler) before the Node object registered; stale cluster state where cloud instances and Node objects are out of sync; instances stuck in pending provisioning during a rolling update.","solutions":["Re-run `kops rolling-update cluster --cloudonly` or re-run the command after the instance has fully joined the cluster and registered its Node object","Verify instance/Node sync with `kubectl get nodes` versus `kops get instances` and remove orphaned instances","Use `kops validate cluster` before rolling updates to ensure all instances have matching Nodes","Ensure the node name equals the instance private DNS name / hostname so registration matches cloud state"],"exampleFix":"// before: rolling update over stale cloud state\nkops rolling-update cluster mycluster.k8s.local --yes\n// after: validate first, then roll\nkops validate cluster mycluster.k8s.local && kops rolling-update cluster mycluster.k8s.local --yes","handlingStrategy":"validation","validationCode":"for _, u := range cloudInstances {\n    if u.Node == nil || u.Node.Name == \"\" {\n        return fmt.Errorf(\"instance %s has no registered k8s Node; skipping drain\", u.ID)\n    }\n}","typeGuard":"func hasRegisteredNode(u *fi.CloudInstance) bool {\n    return u != nil && u.Node != nil && u.Node.Name != \"\"\n}","tryCatchPattern":null,"preventionTips":["Run kops validate cluster before starting a rolling update","Reconcile cloud instances vs `kubectl get nodes` and delete orphans first","Avoid terminating instances out-of-band mid-update"],"tags":["kubernetes","drain","rolling-update","node-registration"],"backgroundTag":"kubernetes-node-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"}