Skip to content

Commit b3ca826

Browse files
authored
Merge pull request kubernetes#74499 from andyzhangx/fix-parse-devicePath-issue
fix parse devicePath issue on Azure Disk
2 parents d500740 + 433ebe3 commit b3ca826

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pkg/volume/azure_dd/attacher.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,23 @@ func (a *azureDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath string,
165165
nodeName := types.NodeName(a.plugin.host.GetHostName())
166166
diskName := volumeSource.DiskName
167167

168-
var lun int32
169-
if runtime.GOOS == "windows" {
168+
lun := int32(-1)
169+
if runtime.GOOS != "windows" {
170+
// on Linux, usually devicePath is like "/dev/disk/azure/scsi1/lun2", get LUN directly
171+
lun, err = getDiskLUN(devicePath)
172+
if err != nil {
173+
klog.V(2).Infof("azureDisk - WaitForAttach: getDiskLUN(%s) failed with error: %v", devicePath, err)
174+
}
175+
}
176+
177+
if lun < 0 {
170178
klog.V(2).Infof("azureDisk - WaitForAttach: begin to GetDiskLun by diskName(%s), DataDiskURI(%s), nodeName(%s), devicePath(%s)",
171179
diskName, volumeSource.DataDiskURI, nodeName, devicePath)
172180
lun, err = diskController.GetDiskLun(diskName, volumeSource.DataDiskURI, nodeName)
173181
if err != nil {
174182
return "", err
175183
}
176184
klog.V(2).Infof("azureDisk - WaitForAttach: GetDiskLun succeeded, got lun(%v)", lun)
177-
} else {
178-
lun, err = getDiskLUN(devicePath)
179-
if err != nil {
180-
return "", err
181-
}
182185
}
183186

184187
exec := a.plugin.host.GetExec(a.plugin.GetPluginName())

0 commit comments

Comments
 (0)