From 61c23dd4d2e07fb2f8b2a019c931c799a3aea025 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Wed, 11 Sep 2024 14:46:19 +0530 Subject: [PATCH] rbd: fail DisableVolumeReplication() if image is not mirror disabled This commit modifies DisableVolumeReplication() to fail if the image is not in mirror disabled state Signed-off-by: Rakshith R --- internal/rbd/replication.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/rbd/replication.go b/internal/rbd/replication.go index badcb12ce62..624eabd3362 100644 --- a/internal/rbd/replication.go +++ b/internal/rbd/replication.go @@ -90,8 +90,10 @@ func DisableVolumeReplication(mirror types.Mirror, return fmt.Errorf("failed to get mirroring info of image: %w", err) } - if info.GetState() == librbd.MirrorImageDisabling.String() { - return fmt.Errorf("%w: image is in disabling state", ErrAborted) + // error out if the image is not in disabled state. + if info.GetState() != librbd.MirrorImageDisabled.String() { + return fmt.Errorf("%w: image is in %q state, expected state %q", ErrAborted, + info.GetState(), librbd.MirrorImageDisabled.String()) } return nil