diff --git a/pkg/driver/diskutils.go b/pkg/driver/diskutils.go index 4c02901..676a139 100644 --- a/pkg/driver/diskutils.go +++ b/pkg/driver/diskutils.go @@ -16,8 +16,10 @@ import ( ) const ( - diskByIDPath = "/dev/disk/by-id" - diskSCWPrefix = "scsi-0SCW_b_ssd_volume-" + diskByIDPath = "/dev/disk/by-id" + // TODO(nox): DEPRECATION B_SSD - remove legacy format when legacy volumes are fully phased out. + legacyDiskSCWPrefix = "scsi-0SCW_b_ssd_volume-" + diskSCWPrefix = "scsi-0SCW_sbs_volume-" diskLuksMapperPrefix = "scw-luks-" diskLuksMapperPath = "/dev/mapper/" @@ -80,6 +82,13 @@ func devicePath(volumeID string) string { return path.Join(diskByIDPath, diskSCWPrefix+volumeID) } +// legacyDevicePath returns the legacy b_ssd volume path +// +// TODO(nox): DEPRECATION B_SSD - remove legacy mode when legacy volumes are fully phased out. +func legacyDevicePath(volumeID string) string { + return path.Join(diskByIDPath, legacyDiskSCWPrefix+volumeID) +} + // EncryptAndOpenDevice encrypts the volume with the given ID with the given passphrase and opens it // If the device is already encrypted (LUKS header present), it will only open the device. func (d *diskUtils) EncryptAndOpenDevice(volumeID string, passphrase string) (string, error) { @@ -211,6 +220,11 @@ func (d *diskUtils) MountToTarget(sourcePath, targetPath, fsType string, mountOp func (d *diskUtils) GetDevicePath(volumeID string) (string, error) { devicePath := devicePath(volumeID) realDevicePath, err := filepath.EvalSymlinks(devicePath) + // TODO(nox): DEPRECATION B_SSD - remove legacy fallback when legacy volumes are fully phased out. + if err != nil && errors.Is(err, fs.ErrNotExist) { + devicePath = legacyDevicePath(volumeID) + realDevicePath, err = filepath.EvalSymlinks(devicePath) + } if err != nil { return "", fmt.Errorf("failed to get real device path: %w", err) }