mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 11:00:25 +00:00
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:
parent
ff0911fb6a
commit
5621f2cfca
@ -851,11 +851,15 @@ func (cs *ControllerServer) DeleteVolume(
|
|||||||
}
|
}
|
||||||
defer cs.OperationLocks.ReleaseDeleteLock(volumeID)
|
defer cs.OperationLocks.ReleaseDeleteLock(volumeID)
|
||||||
|
|
||||||
|
// if this is a migration request volID, delete the volume in backend
|
||||||
if isMigrationVolID(volumeID) {
|
if isMigrationVolID(volumeID) {
|
||||||
log.DebugLog(ctx, "migration volume ID : %s", volumeID)
|
pmVolID, pErr := parseMigrationVolID(volumeID)
|
||||||
err = parseAndDeleteMigratedVolume(ctx, volumeID, cr)
|
if pErr != nil {
|
||||||
if err != nil && !errors.Is(err, ErrImageNotFound) {
|
return nil, status.Error(codes.InvalidArgument, pErr.Error())
|
||||||
return nil, status.Error(codes.Internal, err.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
|
return &csi.DeleteVolumeResponse{}, nil
|
||||||
|
@ -74,15 +74,10 @@ func parseMigrationVolID(vh string) (*migrationVolID, error) {
|
|||||||
return mh, nil
|
return mh, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseAndDeleteMigratedVolume get rbd volume details from the migration volID
|
// deleteMigratedVolume get rbd volume details from the migration volID
|
||||||
// and delete the volume from the cluster, return err if there was an error on the process.
|
// and delete the volume from the cluster, return err if there was an error on the process.
|
||||||
func parseAndDeleteMigratedVolume(ctx context.Context, volumeID string, cr *util.Credentials) error {
|
func deleteMigratedVolume(ctx context.Context, parsedMigHandle *migrationVolID, cr *util.Credentials) error {
|
||||||
parsedMigHandle, err := parseMigrationVolID(volumeID)
|
var err error
|
||||||
if err != nil {
|
|
||||||
log.ErrorLog(ctx, "failed to parse migration volumeID: %s , err: %v", volumeID, err)
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
rv := &rbdVolume{}
|
rv := &rbdVolume{}
|
||||||
|
|
||||||
// fill details to rv struct from parsed migration handle
|
// fill details to rv struct from parsed migration handle
|
||||||
|
Loading…
Reference in New Issue
Block a user