kubernetes/kops · error

DeviceName not set for volume

Error message

DeviceName not set for volume

What it means

buildAdditionalDevices converts a task's list of BlockDeviceMapping into a device-name-keyed map for AWS LaunchConfiguration/LaunchTemplate rendering. Every volume must have an explicit DeviceName; if one is nil the function aborts rather than guessing a name, since AWS maps block devices by device path.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/helper.go:53

	}

	blockDeviceMappings := make(map[string]*BlockDeviceMapping)

	for _, ed := range mt.EphemeralDevices() {
		blockDeviceMappings[ed.DeviceName] = &BlockDeviceMapping{VirtualName: new(ed.VirtualName)}
	}

	return blockDeviceMappings, nil
}

// buildAdditionalDevices is responsible for creating additional volumes in this lc
func buildAdditionalDevices(volumes []*BlockDeviceMapping) (map[string]*BlockDeviceMapping, error) {
	devices := make(map[string]*BlockDeviceMapping)

	// @step: iterate the volumes and create devices from them
	for _, x := range volumes {
		if x.DeviceName == nil {
			return nil, errors.New("DeviceName not set for volume")
		}
		devices[*x.DeviceName] = x
	}

	return devices, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set deviceName on each blockDeviceMapping entry in the InstanceGroup spec (e.g. deviceName: /dev/xvda)
  2. Run kops edit instancegroup <group> and add the missing deviceName, then kops update cluster
  3. If the device is the root volume, set it in rootVolume* fields instead of blockDeviceMappings

Example fix

// before
blockDeviceMappings:
- volumeSize: 100
  volumeType: gp2
// after
blockDeviceMappings:
- deviceName: /dev/xvda
  volumeSize: 100
  volumeType: gp2
Defensive patterns

Strategy: validation

Validate before calling

for i, bdm := range spec.BlockDeviceMappings {
	if bdm.DeviceName == "" { return fmt.Errorf("blockDeviceMappings[%d]: deviceName is required", i) }
}

Try / catch

if _, err := buildAdditionalDevices(volumes); err != nil {
	return fmt.Errorf("invalid blockDeviceMappings: %w", err)
}

Prevention

When it happens

Trigger: Rendering an InstanceGroup (via RenderAWS or RenderTerraform) whose BlockDeviceMappings include a volume with no deviceName set in the cluster spec — e.g. a blockDeviceMapping entry with only volumeSize/volumeType but no deviceName field.

Common situations: A cluster spec where rootVolumeSize was replaced with a custom blockDeviceMapping entry but deviceName was omitted (AWS usually expects /dev/xvda or /dev/nvme0n1); copying task manifests between cloud providers where the field is named differently; hand-edited manifests.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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