]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: defend for primary as part of disable request
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Fri, 28 Feb 2025 19:44:17 +0000 (01:14 +0530)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 24 Apr 2025 15:56:31 +0000 (21:26 +0530)
Other wise we will procceed with disable in below case and end-up not
able to promote the same later:

[root@dhcp53-181 build]#  ./bin/rbd --cluster site-a mirror group demote test_pool/test_group --debug-rbd=0
Group demoted to non-primary
[root@dhcp53-181 build]# ./bin/rbd --cluster site-a mirror group disable test_pool/test_group --debug-rbd=0
2025-03-01T00:46:55.214+0530 7f1cdd71a6c0 -1 librbd::mirror::DisableRequest: 0x56213d4b8f10 handle_get_mirror_info: mirrored image is not primary, add force option to disable mirroring
2025-03-01T00:46:55.215+0530 7f1ce4c39b80 -1 librbd::api::Mirror: image_disable: cannot disable mirroring: (22) Invalid argument
2025-03-01T00:46:55.218+0530 7f1ce4c39b80 -1 librbd::api::Mirror: group_disable: failed to disable mirroring on image: test_image1(22) Invalid argument
2025-03-01T00:46:55.238+0530 7f1cddf1b6c0 -1 librbd::mirror::DisableRequest: 0x56213d17d790 handle_get_mirror_info: mirrored image is not primary, add force option to disable mirroring
2025-03-01T00:46:55.238+0530 7f1ce4c39b80 -1 librbd::api::Mirror: image_disable: cannot disable mirroring: (22) Invalid argument
2025-03-01T00:46:55.241+0530 7f1ce4c39b80 -1 librbd::api::Mirror: group_disable: failed to disable mirroring on image: test_image2(22) Invalid argument
2025-03-01T00:46:55.265+0530 7f1cdd71a6c0 -1 librbd::mirror::DisableRequest: 0x56213d52f290 handle_get_mirror_info: mirrored image is not primary, add force option to disable mirroring
2025-03-01T00:46:55.265+0530 7f1ce4c39b80 -1 librbd::api::Mirror: image_disable: cannot disable mirroring: (22) Invalid argument
2025-03-01T00:46:55.269+0530 7f1ce4c39b80 -1 librbd::api::Mirror: group_disable: failed to disable mirroring on image: test_image3(22) Invalid argument
2025-03-01T00:46:55.293+0530 7f1cddf1b6c0 -1 librbd::mirror::DisableRequest: 0x56213d544620 handle_get_mirror_info: mirrored image is not primary, add force option to disable mirroring
2025-03-01T00:46:55.293+0530 7f1ce4c39b80 -1 librbd::api::Mirror: image_disable: cannot disable mirroring: (22) Invalid argument
2025-03-01T00:46:55.297+0530 7f1ce4c39b80 -1 librbd::api::Mirror: group_disable: failed to disable mirroring on image: test_image4(22) Invalid argument
2025-03-01T00:46:55.316+0530 7f1ce4c39b80 -1 librbd::api::Mirror: group_disable: failed to disable one or more images: (22) Invalid argument
[root@dhcp53-181 build]#  ./bin/rbd --cluster site-a mirror group promote test_pool/test_group --debug-rbd=0
rbd: mirroring not enabled on the group

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
src/librbd/api/Mirror.cc

index a6a7450c6149d0e8c594b21805e93794867b5b96..0b2aa379ff9a23ff0352be9b47a3f80bb315f876 100644 (file)
@@ -2949,9 +2949,9 @@ int Mirror<I>::group_disable(IoCtx& group_ioctx, const char *group_name,
     return r;
   }
 
-  if (state == cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY && !force) {
+  if (state != cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY && !force) {
     lderr(cct) << "group " << group_name
-               << " is non-primary, ideally disable it from primary cluster "
+               << " is not primary, disable is allowed when cluster is primary"
                << " or if you know what you are doing, add a force flag"
                << dendl;
     return -EINVAL;