From: Venky Shankar Date: Fri, 30 Apr 2021 04:46:24 +0000 (-0400) Subject: cephfs-mirror: allow connecting to local cluster using mon address X-Git-Tag: v17.1.0~1931^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f3e36605154b8b38a5f8d33170d332fcc042994;p=ceph.git cephfs-mirror: allow connecting to local cluster using mon address Fixes: http://tracker.ceph.com/issues/50581 Signed-off-by: Venky Shankar --- diff --git a/src/tools/cephfs_mirror/FSMirror.cc b/src/tools/cephfs_mirror/FSMirror.cc index 47dfe530b57c..d18a1563fbea 100644 --- a/src/tools/cephfs_mirror/FSMirror.cc +++ b/src/tools/cephfs_mirror/FSMirror.cc @@ -141,7 +141,7 @@ void FSMirror::init(Context *on_finish) { std::scoped_lock locker(m_lock); int r = connect(g_ceph_context->_conf->name.to_str(), - g_ceph_context->_conf->cluster, &m_cluster); + g_ceph_context->_conf->cluster, &m_cluster, "", "", m_args); if (r < 0) { m_init_failed = true; on_finish->complete(r); diff --git a/src/tools/cephfs_mirror/Utils.cc b/src/tools/cephfs_mirror/Utils.cc index 617ae5ab4a61..6393d1d46ea7 100644 --- a/src/tools/cephfs_mirror/Utils.cc +++ b/src/tools/cephfs_mirror/Utils.cc @@ -18,7 +18,8 @@ namespace cephfs { namespace mirror { int connect(std::string_view client_name, std::string_view cluster_name, - RadosRef *cluster, std::string_view mon_host, std::string_view cephx_key) { + RadosRef *cluster, std::string_view mon_host, std::string_view cephx_key, + std::vector args) { dout(20) << ": connecting to cluster=" << cluster_name << ", client=" << client_name << ", mon_host=" << mon_host << dendl; @@ -40,12 +41,13 @@ int connect(std::string_view client_name, std::string_view cluster_name, cct->_conf.parse_env(cct->get_module_type()); - std::vector args; - r = cct->_conf.parse_argv(args); - if (r < 0) { - derr << ": could not parse environment: " << cpp_strerror(r) << dendl; - cct->put(); - return r; + if (!args.empty()) { + r = cct->_conf.parse_argv(args); + if (r < 0) { + derr << ": could not parse command line args: " << cpp_strerror(r) << dendl; + cct->put(); + return r; + } } cct->_conf.parse_env(cct->get_module_type()); @@ -66,6 +68,8 @@ int connect(std::string_view client_name, std::string_view cluster_name, } } + dout(10) << ": using mon addr=" << cct->_conf.get_val("mon_host") << dendl; + cluster->reset(new librados::Rados()); r = (*cluster)->init_with_context(cct); diff --git a/src/tools/cephfs_mirror/Utils.h b/src/tools/cephfs_mirror/Utils.h index 837b834221ea..76b0c07269ca 100644 --- a/src/tools/cephfs_mirror/Utils.h +++ b/src/tools/cephfs_mirror/Utils.h @@ -10,7 +10,8 @@ namespace cephfs { namespace mirror { int connect(std::string_view client_name, std::string_view cluster_name, - RadosRef *cluster, std::string_view mon_host={}, std::string_view cephx_key={}); + RadosRef *cluster, std::string_view mon_host={}, std::string_view cephx_key={}, + std::vector args={}); int mount(RadosRef cluster, const Filesystem &filesystem, bool cross_check_fscid, MountRef *mount); diff --git a/src/tools/cephfs_mirror/main.cc b/src/tools/cephfs_mirror/main.cc index aceb57bdbb5e..f23e19924564 100644 --- a/src/tools/cephfs_mirror/main.cc +++ b/src/tools/cephfs_mirror/main.cc @@ -18,7 +18,9 @@ void usage() { std::cout << "usage: cephfs-mirror [options...]" << std::endl; std::cout << "options:\n"; - std::cout << " --log-file= file to log debug output\n"; + std::cout << " --mon-host monaddress[:port] connect to specified monitor\n"; + std::cout << " --keyring= path to keyring for local cluster\n"; + std::cout << " --log-file= file to log debug output\n"; std::cout << " --debug-cephfs-mirror=/ set cephfs-mirror debug level\n"; generic_server_usage(); }