From: Prasanna Kumar Kalever Date: Thu, 3 Apr 2025 10:47:39 +0000 (+0530) Subject: rbd_mirror: fix cross namespace group snapshot mirroring X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=33e9b0762bbce68292eb1abf869dbd5cdc5d84e1;p=ceph-ci.git rbd_mirror: fix cross namespace group snapshot mirroring In case if group belongs to non-default namespace, the mirror daemon on secondary is setting an empty mirror peer uuid on non primary demote snapshot. And when previous secondary turns into primary (by an explicit promote request) the previous i.e. non primary demote snapshot is getting unlinked as part of the promote request as there is no mirror peer uuid set on it. Because the previous dependent snapshot is removed, there are split-brain errors leading to recent test failures. This fix makesure to set the right mirror peer uuid on the non primary demote snapshot even if the group belong to non-default namespace. Signed-off-by: Prasanna Kumar Kalever --- diff --git a/src/tools/rbd_mirror/group_replayer/Replayer.cc b/src/tools/rbd_mirror/group_replayer/Replayer.cc index 6805a30db6b..8c323ea9e94 100644 --- a/src/tools/rbd_mirror/group_replayer/Replayer.cc +++ b/src/tools/rbd_mirror/group_replayer/Replayer.cc @@ -767,10 +767,16 @@ void Replayer::create_mirror_snapshot( int r; std::set mirror_peer_uuids; if (snap_state == cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED) { + librados::IoCtx default_ns_io_ctx; + default_ns_io_ctx.dup(m_local_io_ctx); + default_ns_io_ctx.set_namespace(""); std::vector mirror_peers; - r = librbd::cls_client::mirror_peer_list(&m_local_io_ctx, &mirror_peers); + r = librbd::cls_client::mirror_peer_list(&default_ns_io_ctx, &mirror_peers); if (r < 0) { - derr << "failed to list peers: " << cpp_strerror(r) << dendl; + derr << "failed to list mirror peers: " << cpp_strerror(r) << dendl; + locker.unlock(); + on_finish->complete(r); + return; } for (auto &peer : mirror_peers) {