From 9a14499422321e3e9b01b58bb73051ca926d7f8a Mon Sep 17 00:00:00 2001 From: Aurelien GASTON Date: Tue, 5 Mar 2024 15:52:09 +0100 Subject: [PATCH 1/2] fix(sbs): use new SBS volume id convention --- pkg/driver/diskutils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/driver/diskutils.go b/pkg/driver/diskutils.go index 4c02901..c35f6fa 100644 --- a/pkg/driver/diskutils.go +++ b/pkg/driver/diskutils.go @@ -17,7 +17,7 @@ import ( const ( diskByIDPath = "/dev/disk/by-id" - diskSCWPrefix = "scsi-0SCW_b_ssd_volume-" + diskSCWPrefix = "scsi-0SCW_sbs_volume-" diskLuksMapperPrefix = "scw-luks-" diskLuksMapperPath = "/dev/mapper/" From 7491e8eb3dfbaf0a1dae1f42c5d61cc7110ff95b Mon Sep 17 00:00:00 2001 From: Aurelien GASTON Date: Tue, 5 Mar 2024 15:52:58 +0100 Subject: [PATCH 2/2] fix(sbs): fallback to b_ssd volume id convention --- pkg/driver/diskutils.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/driver/diskutils.go b/pkg/driver/diskutils.go index c35f6fa..676a139 100644 --- a/pkg/driver/diskutils.go +++ b/pkg/driver/diskutils.go @@ -16,7 +16,9 @@ import ( ) const ( - diskByIDPath = "/dev/disk/by-id" + 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) }