mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-18 04:10:22 +00:00
rbd: add a check for image mirror disabling state
the rbd mirror state can be in enabled,disabled or disabling state. If the mirroring is not disabled yet and still in disabling state. we need to check for it and return abort error message if the mirroring is still getting disabled. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
aaf6b571b8
commit
c822ad460d
@ -219,10 +219,22 @@ func (rs *ReplicationServer) DisableVolumeReplication(ctx context.Context,
|
|||||||
util.ErrorLog(ctx, err.Error())
|
util.ErrorLog(ctx, err.Error())
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
// TODO: check do we need to return abort after disabling the mirroring
|
// the image state can be still disabling once we disable the mirroring
|
||||||
|
// check the mirroring is disabled or not
|
||||||
|
mirroringInfo, err = rbdVol.getImageMirroringInfo()
|
||||||
|
if err != nil {
|
||||||
|
util.ErrorLog(ctx, err.Error())
|
||||||
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
}
|
||||||
|
if mirroringInfo.State == librbd.MirrorImageDisabling {
|
||||||
|
return nil, status.Errorf(codes.Aborted, "%s is in disabling state", volumeID)
|
||||||
|
}
|
||||||
return &replication.DisableVolumeReplicationResponse{}, nil
|
return &replication.DisableVolumeReplicationResponse{}, nil
|
||||||
case librbd.MirrorImageDisabled:
|
|
||||||
// image is already in disabled state
|
// image is already in disabled state
|
||||||
|
case librbd.MirrorImageDisabled:
|
||||||
|
// image mirroring is still disabling
|
||||||
|
case librbd.MirrorImageDisabling:
|
||||||
|
return nil, status.Errorf(codes.Aborted, "%s is in disabling state", volumeID)
|
||||||
default:
|
default:
|
||||||
// TODO: use string instead of int for returning valid error message
|
// TODO: use string instead of int for returning valid error message
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "image is in %d Mode", mirroringInfo.State)
|
return nil, status.Errorf(codes.InvalidArgument, "image is in %d Mode", mirroringInfo.State)
|
||||||
|
Loading…
Reference in New Issue
Block a user