Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grab snow device path via last character rather than trimming #1546

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/driver/node_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ func (d *nodeService) findDevicePath(devicePath, volumeID, partition string) (st

if util.IsSBE(d.metadata.GetRegion()) {
klog.V(5).InfoS("[Debug] Falling back to snow volume lookup", "devicePath", devicePath)
canonicalDevicePath = "/dev/vd" + strings.TrimPrefix(devicePath, "/dev/xvdb")
// Snow completely ignores the requested device path and mounts volumes starting at /dev/vda .. /dev/vdb .. etc
// Morph the device path to the snow form by chopping off the last letter and prefixing with /dev/vd
// VMs on snow devices are currently limited to 10 block devices each - if that ever exceeds 26 this will need
// to be adapted
canonicalDevicePath = "/dev/vd" + devicePath[len(devicePath)-1:]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np: Can you add a comment here explaining why you're doing this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my own understanding: the 26-volume limit doesn't exist for the current implementation, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rdpsin - Comment added

@hanyuel - no, this is a limitation of both

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why both? I thought the 26-device limitation was from this change taking only the last character of devicePath while the current implementation just trims the prefix.

}

if canonicalDevicePath == "" {
Expand Down
16 changes: 15 additions & 1 deletion pkg/driver/node_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

func TestFindDevicePath(t *testing.T) {
devicePath := "/dev/xvdba"
devicePath := "/dev/xvdaa"
nvmeDevicePath := "/dev/nvme1n1"
snowDevicePath := "/dev/vda"
volumeID := "vol-test"
Expand Down Expand Up @@ -120,6 +120,20 @@ func TestFindDevicePath(t *testing.T) {
},
expectDevicePath: snowDevicePath,
},
{
name: "success: non-standard snow device path",
devicePath: "/dev/sda",
volumeID: volumeID,
partition: "",
expectMock: func(mockMounter MockMounter, mockDeviceIdentifier MockDeviceIdentifier) {
gomock.InOrder(
mockMounter.EXPECT().PathExists(gomock.Eq("/dev/sda")).Return(false, nil),

mockDeviceIdentifier.EXPECT().Lstat(gomock.Eq(nvmeName)).Return(nil, os.ErrNotExist),
)
},
expectDevicePath: snowDevicePath,
},
}
// The partition variant of each case should be the same except the partition
// is expected to be appended to devicePath
Expand Down