From 79e20f9ccaf88d30a2099ff4a10342812d4b45d3 Mon Sep 17 00:00:00 2001 From: Divyen Patel Date: Fri, 22 Jul 2022 16:48:56 -0700 Subject: [PATCH] mark volume detach as success when Node vm is deleted from vcenter (#1879) --- pkg/csi/service/vanilla/controller.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/csi/service/vanilla/controller.go b/pkg/csi/service/vanilla/controller.go index 56dfacfb04..de80dc116f 100644 --- a/pkg/csi/service/vanilla/controller.go +++ b/pkg/csi/service/vanilla/controller.go @@ -1238,8 +1238,14 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con node, err = c.nodeMgr.GetNodeByName(ctx, req.NodeId) } if err != nil { - return nil, csifault.CSIInternalFault, logger.LogNewErrorCodef(log, codes.Internal, - "failed to find VirtualMachine for node:%q. Error: %v", req.NodeId, err) + if err == cnsvsphere.ErrVMNotFound { + log.Infof("Virtual Machine for Node ID: %v is not present in the VC Inventory. "+ + "Marking ControllerUnpublishVolume for Volume: %q as successful.", req.NodeId, req.VolumeId) + return &csi.ControllerUnpublishVolumeResponse{}, "", nil + } else { + return nil, csifault.CSIInternalFault, logger.LogNewErrorCodef(log, codes.Internal, + "failed to find VirtualMachine for node:%q. Error: %v", req.NodeId, err) + } } faultType, err = common.DetachVolumeUtil(ctx, c.manager, node, req.VolumeId) if err != nil {