]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/api: propagate ENOENT error in Mirror::group_get_info() API
authorRamana Raja <rraja@redhat.com>
Tue, 15 Apr 2025 19:16:34 +0000 (15:16 -0400)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 24 Apr 2025 15:56:39 +0000 (21:26 +0530)
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 <rraja@redhat.com>
qa/workunits/rbd/cli_generic.sh
src/librbd/api/Mirror.cc

index cb74dd5c0958a3f884529111656ff3249419c792..493e0d6b002d61732c4a32735449610a234c3184 100755 (executable)
@@ -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
index f52d367b2a312a88570372a59b2cbb4c88b25c24..132c6371c80fcc64792c97afde23541e10158006 100644 (file)
@@ -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;
     }