From: songweibin Date: Thu, 13 Jul 2017 06:41:04 +0000 (+0800) Subject: api/Mirror: make it more understandable when adding peer returns error X-Git-Tag: v12.1.2~193^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d29895a45ac465ebfcf8769f65087318112030e8;p=ceph.git api/Mirror: make it more understandable when adding peer returns error Signed-off-by: songweibin --- diff --git a/src/tools/rbd/action/MirrorPool.cc b/src/tools/rbd/action/MirrorPool.cc index 929ac446d02c..0090a42060b9 100644 --- a/src/tools/rbd/action/MirrorPool.cc +++ b/src/tools/rbd/action/MirrorPool.cc @@ -528,10 +528,25 @@ int execute_peer_add(const po::variables_map &vm) { if (r < 0) { return r; } + + librbd::RBD rbd; + rbd_mirror_mode_t mirror_mode; + r = rbd.mirror_mode_get(io_ctx, &mirror_mode); + if (r < 0) { + std::cerr << "rbd: failed to retrieve mirror mode: " + << cpp_strerror(r) << std::endl; + return r; + } + + if (mirror_mode == RBD_MIRROR_MODE_DISABLED) { + std::cerr << "rbd: failed to add mirror peer: " + << "mirroring must be enabled on the pool " + << pool_name << std::endl; + return -EINVAL; + } // TODO: temporary restriction to prevent adding multiple peers // until rbd-mirror daemon can properly handle the scenario - librbd::RBD rbd; std::vector mirror_peers; r = rbd.mirror_peer_list(io_ctx, &mirror_peers); if (r < 0) {