]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Monitor: clearer output on error during attempt to convert store 121/head
authorJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 20 Mar 2013 13:31:14 +0000 (13:31 +0000)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 20 Mar 2013 13:31:14 +0000 (13:31 +0000)
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/ceph_mon.cc
src/mon/Monitor.cc
src/mon/Monitor.h

index 6a61f3e4983a1f082ceff0f8af4113d7cc44d6bc..4a4df8942e960d650375d8eb3738876ed605bcba 100644 (file)
@@ -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);
index 9f35e0df615b6abb5c15dea94e2368a5e5ad1516..bcebe3a1ccbc1756769e98c70adddfb2ae84d602 100644 (file)
@@ -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;
 }
index 55f27c7822dffea4d399f12b53470e0a28ee6d30..f0cbe39d0128d83307ca7dd22bd086c7db5ceffe 100644 (file)
@@ -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: