diff --git a/infrastructure/devicepathresolver/mapped_device_path_resolver.go b/infrastructure/devicepathresolver/mapped_device_path_resolver.go index 2d29efd42..27fcb90e3 100644 --- a/infrastructure/devicepathresolver/mapped_device_path_resolver.go +++ b/infrastructure/devicepathresolver/mapped_device_path_resolver.go @@ -1,7 +1,6 @@ package devicepathresolver import ( - "fmt" "os" "path/filepath" "strings" @@ -58,17 +57,16 @@ func (dpr mappedDevicePathResolver) findPossibleDevice(devicePath string) (strin needsMapping := strings.HasPrefix(devicePath, "/dev/sd") if needsMapping { //nolint:nestif - pathLetterSuffix := strings.Split(devicePath, "/dev/sd")[1] - pathNumberSuffix := fmt.Sprintf("%d", pathLetterSuffix[0]-97) // a=0, b=1 - - possiblePaths := []string{ - "/dev/xvd" + pathLetterSuffix, // Xen - "/dev/vd" + pathLetterSuffix, // KVM - "/dev/sd" + pathLetterSuffix, - "/dev/nvme" + pathNumberSuffix + "n1", // Nitro instances with Noble + pathSuffix := strings.Split(devicePath, "/dev/sd")[1] + + possiblePrefixes := []string{ + "/dev/xvd", // Xen + "/dev/vd", // KVM + "/dev/sd", } - for _, path := range possiblePaths { + for _, prefix := range possiblePrefixes { + path := prefix + pathSuffix if dpr.fs.FileExists(path) { return path, true, nil } diff --git a/infrastructure/devicepathresolver/mapped_device_path_resolver_test.go b/infrastructure/devicepathresolver/mapped_device_path_resolver_test.go index d378241fd..eb6f08bb8 100644 --- a/infrastructure/devicepathresolver/mapped_device_path_resolver_test.go +++ b/infrastructure/devicepathresolver/mapped_device_path_resolver_test.go @@ -90,20 +90,6 @@ var _ = Describe("mappedDevicePathResolver", func() { }) }) - Context("when a matching /dev/nvmeXn1 device is found", func() { - BeforeEach(func() { - err := fs.WriteFile("/dev/nvme0n1", []byte{}) - Expect(err).NotTo(HaveOccurred()) - }) - - It("returns the match", func() { - realPath, timedOut, err := resolver.GetRealDevicePath(diskSettings) - Expect(err).NotTo(HaveOccurred()) - Expect(timedOut).To(BeFalse()) - Expect(realPath).To(Equal("/dev/nvme0n1")) - }) - }) - Context("when no matching device is found the first time", func() { Context("when the timeout has not expired", func() { BeforeEach(func() {