Skip to content

Commit

Permalink
Check for NotFound fault during DeleteVolume
Browse files Browse the repository at this point in the history
  • Loading branch information
chethanv28 committed Oct 8, 2019
1 parent 86bae8c commit 8f1ef2f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/common/cns-lib/volume/manager.go
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/vmware/govmomi/cns"
cnstypes "github.com/vmware/govmomi/cns/types"
vimtypes "github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vim25/soap"
"k8s.io/klog"

cnsvsphere "sigs.k8s.io/vsphere-csi-driver/pkg/common/cns-lib/vsphere"
Expand Down Expand Up @@ -288,7 +290,14 @@ func (m *volumeManager) DeleteVolume(volumeID string, deleteDisk bool) error {
cnsVolumeIDList = append(cnsVolumeIDList, cnsVolumeID)
task, err := m.virtualCenter.CnsClient.DeleteVolume(ctx, cnsVolumeIDList, deleteDisk)
if err != nil {
klog.Errorf("CNS DeleteVolume failed from vCenter %q with err: %v", m.virtualCenter.Config.Host, err)
if soap.IsSoapFault(err) {
soapFault := soap.ToSoapFault(err)
if _, ok := soapFault.VimFault().(vimtypes.NotFound); ok {
klog.V(2).Info("VolumeID: %q, not found. Returning success for this operation since the volume is not present", volumeID)
return nil
}
}
klog.Errorf("CNS DeleteVolume failed from the vCenter %q with err: %v", m.virtualCenter.Config.Host, err)
return err
}
// Get the taskInfo
Expand Down

0 comments on commit 8f1ef2f

Please sign in to comment.