rbd: split the parsing and deletion logic to its own functions.

parseAndDeleteMigratedVolume() prviously clubbed the logic of
parsing of migration volume handle and then continued with the
deletion of the volume. however this commit split this
logic into two, ie parsing has been done in parseMigrationVolID()
and DeleteMigratedVolume() deletes the backend volume.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal
2021-10-25 14:47:12 +05:30
committed by mergify[bot]
parent ff0911fb6a
commit 5621f2cfca
2 changed files with 11 additions and 12 deletions

View File

@ -851,11 +851,15 @@ func (cs *ControllerServer) DeleteVolume(
}
defer cs.OperationLocks.ReleaseDeleteLock(volumeID)
// if this is a migration request volID, delete the volume in backend
if isMigrationVolID(volumeID) {
log.DebugLog(ctx, "migration volume ID : %s", volumeID)
err = parseAndDeleteMigratedVolume(ctx, volumeID, cr)
if err != nil && !errors.Is(err, ErrImageNotFound) {
return nil, status.Error(codes.Internal, err.Error())
pmVolID, pErr := parseMigrationVolID(volumeID)
if pErr != nil {
return nil, status.Error(codes.InvalidArgument, pErr.Error())
}
pErr = deleteMigratedVolume(ctx, pmVolID, cr)
if pErr != nil && !errors.Is(pErr, ErrImageNotFound) {
return nil, status.Error(codes.Internal, pErr.Error())
}
return &csi.DeleteVolumeResponse{}, nil