From 448be70682ec695149e209a0a5f43678a7b81135 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 30 Mar 2021 10:14:32 +0530 Subject: [PATCH] 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 --- internal/rbd/replicationcontrollerserver.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/rbd/replicationcontrollerserver.go b/internal/rbd/replicationcontrollerserver.go index 71fc0cf44..6b6cf69a0 100644 --- a/internal/rbd/replicationcontrollerserver.go +++ b/internal/rbd/replicationcontrollerserver.go @@ -214,6 +214,11 @@ func (rs *ReplicationServer) DisableVolumeReplication(ctx context.Context, } 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: if !force && !mirroringInfo.Primary { 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 &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: // TODO: use string instead of int for returning valid error message return nil, status.Errorf(codes.InvalidArgument, "image is in %d Mode", mirroringInfo.State)