From 00f947b05f42ac3100cfcf5c6ab3a82663c821ea Mon Sep 17 00:00:00 2001 From: RAJAT HANDE Date: Tue, 26 Nov 2024 18:41:39 -0500 Subject: [PATCH] Fix the santisedDevices logic for ubuntu nodes --- pkg/util/disk/iscsi.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/util/disk/iscsi.go b/pkg/util/disk/iscsi.go index 52bad4762e..d90f43a874 100644 --- a/pkg/util/disk/iscsi.go +++ b/pkg/util/disk/iscsi.go @@ -268,10 +268,12 @@ func GetDiskPathFromBindDeviceFilePath(logger *zap.SugaredLogger, mountPath stri var sanitizedDevices []string for _, dev := range devices { - sanitizedDevice := strings.TrimPrefix(dev, "devtmpfs[") - sanitizedDevice = strings.TrimSuffix(sanitizedDevice, "]") - sanitizedDevice = filepath.Clean(sanitizedDevice) // Fix extra slashes - sanitizedDevices = append(sanitizedDevices, sanitizedDevice) + if prefixEnd := strings.Index(dev, "["); prefixEnd != -1 { + sanitizedDevice := dev[prefixEnd+1:] // Start after `[` + sanitizedDevice = strings.TrimSuffix(sanitizedDevice, "]") + sanitizedDevice = filepath.Clean(sanitizedDevice) // Fix extra slashes + sanitizedDevices = append(sanitizedDevices, sanitizedDevice) + } } if len(sanitizedDevices) != 1 {