From 9eac5b50dda38c00d29f213fecad250725dd3221 Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Tue, 15 Jun 2021 15:03:55 -0400 Subject: [PATCH] Do not throw error when we can't get canonical path --- .../src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go index 350029a04c5e7..fb9db9eb78226 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go +++ b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vsphere.go @@ -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})