cephfs: DeleteVolume should assume the volume to be already deleted if metadata doesn't exist

This commit is contained in:
gman 2019-02-25 18:07:28 +01:00
parent e5dbea15d3
commit ce3affcc6a

View File

@ -97,8 +97,9 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}, nil }, nil
} }
// DeleteVolume deletes the volume in backend and removes the volume metadata // DeleteVolume deletes the volume in backend
// from store // and removes the volume metadata from store
// nolint: gocyclo
func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) { func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
if err := cs.validateDeleteVolumeRequest(); err != nil { if err := cs.validateDeleteVolumeRequest(); err != nil {
klog.Errorf("DeleteVolumeRequest validation failed: %v", err) klog.Errorf("DeleteVolumeRequest validation failed: %v", err)
@ -108,11 +109,15 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
var ( var (
volID = volumeID(req.GetVolumeId()) volID = volumeID(req.GetVolumeId())
secrets = req.GetSecrets() secrets = req.GetSecrets()
err error
) )
ce := &controllerCacheEntry{} ce := &controllerCacheEntry{}
if err = cs.MetadataStore.Get(string(volID), ce); err != nil { if err := cs.MetadataStore.Get(string(volID), ce); err != nil {
if err, ok := err.(*util.CacheEntryNotFound); ok {
klog.Infof("cephfs: metadata for volume %s not found, assuming the volume to be already deleted (%v)", volID, err)
return &csi.DeleteVolumeResponse{}, nil
}
return nil, status.Error(codes.Internal, err.Error()) return nil, status.Error(codes.Internal, err.Error())
} }