kubernetes/kops · error
instanceGroup cannot be nil
Error message
instanceGroup cannot be nil
What it means
BuildConfig requires a non-nil InstanceGroup to generate the NodeUp config. Passing nil means the caller lost track of which instance group the node belongs to, so role-specific config (control-plane vs node) cannot be produced.
Source
Thrown at pkg/nodemodel/nodeupconfigbuilder.go:180
configBuilder := nodeUpConfigBuilder{
assetBuilder: assetBuilder,
channelsManifest: channelsManifest,
configBase: configBase,
cluster: cluster,
etcdManifests: etcdManifests,
images: images,
encryptionConfigSecretHash: encryptionConfigSecretHash,
}
return &configBuilder, nil
}
// BuildConfig returns the NodeUp config and auxiliary config.
func (n *nodeUpConfigBuilder) BuildConfig(ig *kops.InstanceGroup, wellKnownAddresses model.WellKnownAddresses, keysets map[string]*fi.Keyset) (*nodeup.Config, *nodeup.BootConfig, error) {
cluster := n.cluster
if ig == nil {
return nil, nil, fmt.Errorf("instanceGroup cannot be nil")
}
role := ig.Spec.Role
if role == "" {
return nil, nil, fmt.Errorf("cannot determine role for instance group: %v", ig.ObjectMeta.Name)
}
isMaster := role.HasControlPlane()
hasAPIServer := isMaster || role.HasAPIServer()
config, bootConfig := nodeup.NewConfig(cluster, ig)
igModel, err := kopsmodel.ForInstanceGroup(cluster, ig)
if err != nil {
return nil, nil, fmt.Errorf("building instance group model: %w", err)
}
if !hasAPIServer && n.assetBuilder.KubeletSupportedVersion != "" {View on GitHub (pinned to 4c8573c808)
Solutions
- Ensure the InstanceGroup is resolved for the node before calling BuildConfig
- Check that the node's InstanceGroup lookup (by node labels/name) succeeds — an unmatched node usually indicates the IG was deleted or renamed
- Pass the correct *kops.InstanceGroup from the caller (e.g. from nodeup bootstrap data) instead of nil
Example fix
// before
config, _, err := builder.BuildConfig(nil, addresses, keysets)
// after
ig, err := findInstanceGroup(nodeName)
if err != nil { return err }
config, _, err := builder.BuildConfig(ig, addresses, keysets) Defensive patterns
Strategy: validation
Validate before calling
if ig == nil {
return fmt.Errorf("refusing BuildConfig: instance group unresolved for node")
} Type guard
func igResolved(ig *kops.InstanceGroup) bool { return ig != nil } Prevention
- Resolve the InstanceGroup (labels/name lookup) before building nodeup config
- Fail fast upstream when IG lookup returns nil instead of passing it through
- Keep IG deletion/renames coordinated with node bootstrapping
When it happens
Trigger: BuildConfig called with ig == nil, e.g. when nodeup model building fails to map a node/instance to its InstanceGroup before building config.
Common situations: Node not associated with any instance group; a nil IG passed from the nodeup bootstrap path due to lookup failure; programmatic callers of BuildConfig with uninitialized variable.
Related errors
- cannot determine role for instance group: %v
- building instance group model: %w
- did not find owner for node %q
- invalid InstanceGroup name: %v
- error building InstanceGroup from CAPI Machine: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/e77c893ed79b059d.
Report an issue: GitHub.