From: Yehuda Sadeh Date: Fri, 13 Nov 2015 18:48:19 +0000 (-0800) Subject: rgw: translate source_zone param into source zone id X-Git-Tag: v10.1.0~354^2~213 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4f17bbb555abe4bdc261567274d0767addcd7899;p=ceph.git rgw: translate source_zone param into source zone id operations are done using the zone id, not the zone name Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index c5da69b7fe49..9d22dc2fe02d 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1591,7 +1591,8 @@ int main(int argc, char **argv) string err; long long tmp = 0; - string source_zone; + string source_zone_name; + string source_zone; /* zone id */ for (std::vector::iterator i = args.begin(); i != args.end(); ) { if (ceph_argparse_double_dash(args, i)) { @@ -1851,7 +1852,7 @@ int main(int argc, char **argv) list::iterator iter; get_str_list(val, endpoints); } else if (ceph_argparse_witharg(args, i, &val, "--source-zone", (char*)NULL)) { - source_zone = val; + source_zone_name = val; } else if (strncmp(*i, "-", 1) == 0) { cerr << "ERROR: invalid flag " << *i << std::endl; return EINVAL; @@ -1968,6 +1969,13 @@ int main(int argc, char **argv) return 5; //EIO } + if (!source_zone_name.empty()) { + if (!store->find_zone_id_by_name(source_zone_name, &source_zone)) { + cerr << "WARNING: cannot find source zone id for name=" << source_zone_name << std::endl; + source_zone = source_zone_name; + } + } + rgw_user_init(store); rgw_bucket_init(store->meta_mgr); diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index ac8b1362d4b7..4aaf9125489c 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -356,12 +356,13 @@ int RGWRemoteDataLog::init(const string& _source_zone, RGWRESTConn *_conn) return 0; } + source_zone = _source_zone; + CephContext *cct = store->ctx(); async_rados = new RGWAsyncRadosProcessor(store, cct->_conf->rgw_num_async_rados_threads); async_rados->start(); conn = _conn; - source_zone = _source_zone; int ret = http_manager.set_threaded(); if (ret < 0) { @@ -1274,7 +1275,7 @@ int RGWRemoteDataLog::run_sync(int num_shards, rgw_data_sync_status& sync_status int RGWDataSyncStatusManager::init() { - conn = store->get_zone_conn_by_name(source_zone); + conn = store->get_zone_conn_by_id(source_zone); if (!conn) { ldout(store->ctx(), 0) << "connection object to zone " << source_zone << " does not exist" << dendl; return -EINVAL; @@ -2310,7 +2311,7 @@ RGWCoroutine *RGWRemoteBucketLog::run_sync_cr() int RGWBucketSyncStatusManager::init() { - conn = store->get_zone_conn_by_name(source_zone); + conn = store->get_zone_conn_by_id(source_zone); if (!conn) { ldout(store->ctx(), 0) << "connection object to zone " << source_zone << " does not exist" << dendl; return -EINVAL; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index aa9e23dc3435..8440d3ff8140 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -3340,6 +3340,7 @@ int RGWRados::init_complete() Mutex::Locker dl(data_sync_thread_lock); for (map::iterator iter = zone_conn_map.begin(); iter != zone_conn_map.end(); ++iter) { + ldout(cct, 5) << "starting data sync thread for zone " << iter->first << dendl; RGWDataSyncProcessorThread *thread = new RGWDataSyncProcessorThread(this, iter->first); ret = thread->init(); if (ret < 0) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 4ba659093c8a..dcdbc9ea40de 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1847,6 +1847,15 @@ public: return get_zone_conn_by_id(i->second); } + bool find_zone_id_by_name(const string& name, string *id) { + auto i = zone_id_by_name.find(name); + if (i == zone_id_by_name.end()) { + return false; + } + *id = i->second; + return true; + } + int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) { int ret = 0; if (id == get_zonegroup().get_id()) {