From 3a0fb103c2819da1d0afb493e672f5c8e2ddfcc7 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Mon, 16 Apr 2018 03:10:33 +0000 Subject: [PATCH] fix devicePath update issue in Azure WaitForAttach func add WaitForAttach logging --- pkg/volume/azure_dd/attacher.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pkg/volume/azure_dd/attacher.go b/pkg/volume/azure_dd/attacher.go index c422ffd5da7..3a00b86d214 100644 --- a/pkg/volume/azure_dd/attacher.go +++ b/pkg/volume/azure_dd/attacher.go @@ -150,27 +150,36 @@ func (a *azureDiskAttacher) VolumesAreAttached(specs []*volume.Spec, nodeName ty func (a *azureDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath string, _ *v1.Pod, timeout time.Duration) (string, error) { var err error - lun, err := strconv.Atoi(devicePath) - if err != nil { - return "", fmt.Errorf("azureDisk - Wait for attach expect device path as a lun number, instead got: %s (%v)", devicePath, err) - } volumeSource, err := getVolumeSource(spec) if err != nil { return "", err } + diskController, err := getDiskController(a.plugin.host) + if err != nil { + return "", err + } + + nodeName := types.NodeName(a.plugin.host.GetHostName()) + diskName := volumeSource.DiskName + + glog.V(5).Infof("azureDisk - WaitForAttach: begin to GetDiskLun by diskName(%s), DataDiskURI(%s), nodeName(%s), devicePath(%s)", + diskName, volumeSource.DataDiskURI, nodeName, devicePath) + lun, err := diskController.GetDiskLun(diskName, volumeSource.DataDiskURI, nodeName) + if err != nil { + return "", err + } + glog.V(5).Infof("azureDisk - WaitForAttach: GetDiskLun succeeded, got lun(%v)", lun) exec := a.plugin.host.GetExec(a.plugin.GetPluginName()) io := &osIOHandler{} scsiHostRescan(io, exec) - diskName := volumeSource.DiskName - nodeName := a.plugin.host.GetHostName() newDevicePath := "" err = wait.Poll(1*time.Second, timeout, func() (bool, error) { - if newDevicePath, err = findDiskByLun(lun, io, exec); err != nil { + if newDevicePath, err = findDiskByLun(int(lun), io, exec); err != nil { return false, fmt.Errorf("azureDisk - WaitForAttach ticker failed node (%s) disk (%s) lun(%v) err(%s)", nodeName, diskName, lun, err) }