kubernetes/kops · error

node name not set

Error message

node name not set

What it means

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.

Source

Thrown at pkg/instancegroups/instancegroups.go:680

		}
		return fmt.Errorf("error deleting instance %q: %v", id, err)
	}

	return nil
}

// drainNode drains a K8s node.
func (c *RollingUpdateCluster) drainNode(ctx context.Context, u *cloudinstances.CloudInstance) error {
	if c.K8sClient == nil {
		return fmt.Errorf("K8sClient not set")
	}

	if u.Node == nil {
		return fmt.Errorf("node not set")
	}

	if u.Node.Name == "" {
		return fmt.Errorf("node name not set")
	}

	helper := &drain.Helper{
		Ctx:                 ctx,
		Client:              c.K8sClient,
		Force:               true,
		GracePeriodSeconds:  -1,
		IgnoreAllDaemonSets: true,
		Out:                 os.Stdout,
		ErrOut:              os.Stderr,
		Timeout:             c.DrainTimeout,

		// The zero value would retry evictions without any delay
		EvictErrorRetryDelay: 5 * time.Second,

		// We want to proceed even when pods are using emptyDir volumes
		DeleteEmptyDirData: true,
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. 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
  2. Verify instance/Node sync with `kubectl get nodes` versus `kops get instances` and remove orphaned instances
  3. Use `kops validate cluster` before rolling updates to ensure all instances have matching Nodes
  4. Ensure the node name equals the instance private DNS name / hostname so registration matches cloud state

Example fix

// before: rolling update over stale cloud state
kops rolling-update cluster mycluster.k8s.local --yes
// after: validate first, then roll
kops validate cluster mycluster.k8s.local && kops rolling-update cluster mycluster.k8s.local --yes
Defensive patterns

Strategy: validation

Validate before calling

for _, u := range cloudInstances {
    if u.Node == nil || u.Node.Name == "" {
        return fmt.Errorf("instance %s has no registered k8s Node; skipping drain", u.ID)
    }
}

Type guard

func hasRegisteredNode(u *fi.CloudInstance) bool {
    return u != nil && u.Node != nil && u.Node.Name != ""
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/211b906000a33e53. Report an issue: GitHub.