]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: prevent adding multiple mirror peers to a single pool 14545/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 10 Mar 2017 15:56:38 +0000 (10:56 -0500)
committerNathan Cutler <ncutler@suse.com>
Thu, 13 Apr 2017 21:41:04 +0000 (23:41 +0200)
The rbd-mirror daemon does not currently support replication
from multiple peers. Until that is supported, add a temporary
restriction to prevent confusion.

Fixes: http://tracker.ceph.com/issues/19256
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit c0c9d1014d57b3d5b95e7513fcc38d04b9ea5165)

src/tools/rbd/action/MirrorPool.cc

index 4552db9b05cbf634d0dfd1ac5cb037bc7f4a5608..0c31c4e3f11ddbd20aa42527b40fec507527bae2 100644 (file)
@@ -153,7 +153,20 @@ int execute_peer_add(const po::variables_map &vm) {
     return r;
   }
 
+  // TODO: temporary restriction to prevent adding multiple peers
+  // until rbd-mirror daemon can properly handle the scenario
   librbd::RBD rbd;
+  std::vector<librbd::mirror_peer_t> mirror_peers;
+  r = rbd.mirror_peer_list(io_ctx, &mirror_peers);
+  if (r < 0) {
+    std::cerr << "rbd: failed to list mirror peers" << std::endl;
+    return r;
+  }
+  if (!mirror_peers.empty()) {
+    std::cerr << "rbd: multiple peers are not currently supported" << std::endl;
+    return -EINVAL;
+  }
+
   std::string uuid;
   r = rbd.mirror_peer_add(io_ctx, &uuid, remote_cluster, remote_client_name);
   if (r < 0) {