From 4bb600770f021c42fce0fa7f2e579e089563e15d Mon Sep 17 00:00:00 2001 From: Ramana Raja Date: Tue, 15 Apr 2025 15:16:34 -0400 Subject: [PATCH] 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 --- qa/workunits/rbd/cli_generic.sh | 6 ++++++ src/librbd/api/Mirror.cc | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qa/workunits/rbd/cli_generic.sh b/qa/workunits/rbd/cli_generic.sh index cb74dd5c095..493e0d6b002 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 29d9e826468..0a3aa6a320b 100644 --- a/src/librbd/api/Mirror.cc +++ b/src/librbd/api/Mirror.cc @@ -560,7 +560,7 @@ struct C_GroupGetInfo : public Context { } void finish(int r) override { - if (r < 0 && r != -ENOENT) { + if (r < 0) { on_finish->complete(r); return; } -- 2.39.5