From c29812cdaf2a0a19e23c365d8f751ceb35a371ed Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Wed, 20 Mar 2013 13:31:14 +0000 Subject: [PATCH] mon: Monitor: clearer output on error during attempt to convert store Signed-off-by: Joao Eduardo Luis --- src/ceph_mon.cc | 9 +++++++-- src/mon/Monitor.cc | 27 ++++++++++++++++++++------- src/mon/Monitor.h | 8 +++++++- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 6a61f3e4983a1..4a4df8942e960 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -224,8 +224,14 @@ int main(int argc, const char **argv) { Monitor::StoreConverter converter(g_conf->mon_data); - if (converter.needs_conversion()) + int ret = converter.needs_conversion(); + if (ret > 0) { assert(!converter.convert()); + } else if (ret < 0) { + derr << "found errors while attempting to convert the monitor store: " + << cpp_strerror(ret) << dendl; + exit(1); + } } MonitorDBStore store(g_conf->mon_data); @@ -233,7 +239,6 @@ int main(int argc, const char **argv) if (err < 0) { cerr << argv[0] << ": error opening mon data store at '" << g_conf->mon_data << "': " << cpp_strerror(err) << std::endl; - cerr << "Have you run '--mkfs'?" << std::endl; exit(1); } assert(err == 0); diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 9f35e0df615b6..bcebe3a1ccbc1 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -4098,9 +4098,9 @@ bool Monitor::StoreConverter::_check_gv_store() return (features.incompat.contains(CEPH_MON_FEATURE_INCOMPAT_GV)); } -bool Monitor::StoreConverter::needs_conversion() +int Monitor::StoreConverter::needs_conversion() { - bool ret = false; + int ret = 0; dout(10) << __func__ << dendl; _init(); @@ -4109,17 +4109,23 @@ bool Monitor::StoreConverter::needs_conversion() dout(1) << "check for old monitor store format" << dendl; int err = store->mount(); if (err < 0) { - dout(0) << "unable to mount monitor store; are you sure it exists?" << dendl; - dout(0) << "error: " << cpp_strerror(err) << dendl; - assert(0 == "non-existent store in mon data directory"); + if (err == -ENOENT) { + derr << "unable to mount monitor store: " + << cpp_strerror(err) << dendl; + } else { + derr << "it appears that another monitor is running: " + << cpp_strerror(err) << dendl; + } + ret = err; + goto out; } - assert(!store->mount()); + assert(err == 0); bufferlist magicbl; if (store->exists_bl_ss("magic", 0)) { if (_check_gv_store()) { dout(1) << "found old GV monitor store format " << "-- should convert!" << dendl; - ret = true; + ret = 1; } else { dout(0) << "Existing monitor store has not been converted " << "to 0.52 (bobtail) format" << dendl; @@ -4127,7 +4133,14 @@ bool Monitor::StoreConverter::needs_conversion() } } assert(!store->umount()); + } else { + if (db->exists("mon_convert", "on_going")) { + ret = -EEXIST; + derr << "there is an on-going (maybe aborted?) conversion." << dendl; + derr << "you should check what happened" << dendl; + } } +out: _deinit(); return ret; } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 55f27c7822dff..f0cbe39d0128d 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -1451,7 +1451,13 @@ public: highest_last_pn(0), highest_accepted_pn(0) { } - bool needs_conversion(); + /** + * Check if store needs to be converted from old format to a + * k/v store. + * + * @returns 0 if store doesn't need conversion; 1 if it does; <0 if error + */ + int needs_conversion(); int convert(); private: -- 2.39.5