From: Ramana Raja Date: Tue, 15 Apr 2025 19:16:34 +0000 (-0400) Subject: librbd/api: propagate ENOENT error in Mirror::group_get_info() API X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8bbeb4d9d3562e92a3fcfe8b6ba9832da3a0f093;p=ceph.git librbd/api: propagate ENOENT error in Mirror::group_get_info() API The ENOENT error was ignored by the librbd API that retrieves mirror group information. This manifests as a bug in the mirror group snapshot scheduler, where the scheduler utilized this API to prevent scheduler commands on groups that are not enabled for snapshot-based mirroring. Since the librbd API masked the ENOENT error, the scheduler's check for mirror group mode was compromised, resulting in scheduler commands unexpectedly succeeding on groups that were not enabled for snapshot-based mirroring. Therefore, allow the ENOENT error from the API that retrieves mirror group information to surface. This fixes the spurious mirror group mode check in the mirror snapshot scheduler. Additionally, add a test to ensure that group snapshot schedule commands fail on a group not enabled for mirroring. Signed-off-by: Ramana Raja --- diff --git a/qa/workunits/rbd/cli_generic.sh b/qa/workunits/rbd/cli_generic.sh index cb74dd5c0958a..493e0d6b002d6 100755 --- a/qa/workunits/rbd/cli_generic.sh +++ b/qa/workunits/rbd/cli_generic.sh @@ -1536,6 +1536,12 @@ test_mirror_group_snapshot_schedule() { rbd group image add rbd2/ns1/gp1 rbd2/ns1/img1 rbd group image add rbd2/ns1/gp1 rbd2/ns1/img2 + # group snapshot schedule commands should fail when mirroring is not + # enabled on the group + expect_fail rbd mirror group snapshot schedule add -p rbd2/ns1 --group gp1 1m + expect_fail rbd mirror group snapshot schedule rm -p rbd2/ns1 --group gp1 + expect_fail rbd mirror group snapshot schedule ls -p rbd2/ns1 --group gp1 + test "$(rbd group snap ls rbd2/ns1/gp1 | grep -c mirror.primary)" = '0' rbd mirror group enable rbd2/ns1/gp1 snapshot diff --git a/src/librbd/api/Mirror.cc b/src/librbd/api/Mirror.cc index f52d367b2a312..132c6371c80fc 100644 --- a/src/librbd/api/Mirror.cc +++ b/src/librbd/api/Mirror.cc @@ -538,7 +538,7 @@ struct C_GroupGetInfo : public Context { } void finish(int r) override { - if (r < 0 && r != -ENOENT) { + if (r < 0) { on_finish->complete(r); return; }