rbd: early check for disabled,disabling in DisableVolumeReplication

added early check for disabling and disabled
image mirroring state in DisableVolumeReplication

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2021-03-30 10:14:32 +05:30 committed by mergify[bot]
parent fb3f7fe202
commit 448be70682

View File

@ -214,6 +214,11 @@ func (rs *ReplicationServer) DisableVolumeReplication(ctx context.Context,
} }
switch mirroringInfo.State { switch mirroringInfo.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)
case librbd.MirrorImageEnabled: case librbd.MirrorImageEnabled:
if !force && !mirroringInfo.Primary { if !force && !mirroringInfo.Primary {
return nil, status.Error(codes.InvalidArgument, "image is in non-primary state") return nil, status.Error(codes.InvalidArgument, "image is in non-primary state")
@ -234,11 +239,6 @@ func (rs *ReplicationServer) DisableVolumeReplication(ctx context.Context,
return nil, status.Errorf(codes.Aborted, "%s is in disabling state", volumeID) return nil, status.Errorf(codes.Aborted, "%s is in disabling state", volumeID)
} }
return &replication.DisableVolumeReplicationResponse{}, nil return &replication.DisableVolumeReplicationResponse{}, nil
// 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)