Skip to content

Commit

Permalink
Truncate deviceName if longer than 20 chars (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
sujeet01 authored Sep 27, 2024
1 parent 8138d73 commit f42e2a1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,13 @@ func validateDeviceName(volume *storagev1alpha1.Volume, machine *computev1alpha1
device := ptr.Deref[string](va.Device, "")
if va.Name == vaName && device != "" {
klog.InfoS("Found device in machine status to use for volume", "Device", device, "Volume", client.ObjectKeyFromObject(volume))
return "/dev/disk/by-id/virtio-" + device + "-" + handle, nil
deviceName := device + "-" + handle
// if deviceName is longer then 20 chars truncate it
// see https://github.com/torvalds/linux/blob/v6.6/include/uapi/linux/virtio_blk.h#L58
if len(deviceName) > 20 {
deviceName = deviceName[:20]
}
return "/dev/disk/by-id/virtio-" + deviceName, nil
}
}
}
Expand Down

0 comments on commit f42e2a1

Please sign in to comment.