Skip to content

Commit

Permalink
mark volume detach as success when Node vm is deleted from vcenter (k…
Browse files Browse the repository at this point in the history
  • Loading branch information
divyenpatel committed Aug 10, 2022
1 parent 19bf51c commit a6c48a1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/csi/service/vanilla/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,14 @@ func (c *controller) ControllerUnpublishVolume(ctx context.Context, req *csi.Con
volumeType = prometheus.PrometheusBlockVolumeType
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 {
Expand Down

0 comments on commit a6c48a1

Please sign in to comment.