Do not throw error when we can't get canonical path

This commit is contained in:
Hemant Kumar 2021-06-15 15:03:55 -04:00
parent 8eef6438e6
commit eadfe46e03

View File

@ -936,11 +936,10 @@ func (vs *VSphere) AttachDisk(vmDiskPath string, storagePolicyName string, nodeN
return "", err
}
// try and get canonical path for disk and if we can't throw error
vmDiskPath, err = getcanonicalVolumePath(ctx, vm.Datacenter, vmDiskPath)
if err != nil {
klog.Errorf("failed to get canonical path for %s on node %s: %v", vmDiskPath, convertToString(nodeName), err)
return "", err
// try and get canonical path for disk and if we can't use provided vmDiskPath
canonicalPath, pathFetchErr := getcanonicalVolumePath(ctx, vm.Datacenter, vmDiskPath)
if canonicalPath != "" && pathFetchErr == nil {
vmDiskPath = canonicalPath
}
diskUUID, err = vm.AttachDisk(ctx, vmDiskPath, &vclib.VolumeOptions{SCSIControllerType: vclib.PVSCSIControllerType, StoragePolicyName: storagePolicyName})