diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2012-12-11 13:41:50 -0800 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-12-11 15:08:58 -0800 |
commit | 29307d3b32e523da7f25a6c3bc904749790b1e18 (patch) | |
tree | edb07f29e0dcdb7abc590531c42bfc785c1a1747 | |
parent | 6007088c537626f69c648e644a1bfb3faec1cba8 (diff) | |
download | ceph-29307d3b32e523da7f25a6c3bc904749790b1e18.tar.gz |
mds: shutdown cleanly if can't authenticate
Fixes: #3590
This was triggered when tried to run mds with cephx enabled
against a mon without cephx support. We didn't handle the
returned error at all, so this one fixes it. It also makes
sure that we don't continue initialization until rotating
keys are in place (as the osd does).
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/ceph_mds.cc | 8 | ||||
-rw-r--r-- | src/mds/MDS.cc | 18 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/ceph_mds.cc b/src/ceph_mds.cc index e6928fb8c0f..36aa58bd579 100644 --- a/src/ceph_mds.cc +++ b/src/ceph_mds.cc @@ -288,11 +288,13 @@ int main(int argc, const char **argv) mds->orig_argv = argv; if (shadow) - mds->init(shadow); + r = mds->init(shadow); else - mds->init(); + r = mds->init(); - messenger->wait(); + if (r >= 0) { + messenger->wait(); + } unregister_async_signal_handler(SIGHUP, sighup_handler); unregister_async_signal_handler(SIGINT, handle_mds_signal); diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index d71405643f4..cbcda25a8dd 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -21,6 +21,7 @@ #include "common/Clock.h" #include "common/signal.h" #include "common/ceph_argparse.h" +#include "common/errno.h" #include "msg/Messenger.h" @@ -459,9 +460,17 @@ int MDS::init(int wanted_state) // tell monc about log_client so it will know about mon session resets monc->set_log_client(&clog); - monc->authenticate(); - monc->wait_auth_rotating(30.0); - + int r = monc->authenticate(); + if (r < 0) { + derr << "ERROR: failed to authenticate: " << cpp_strerror(-r) << dendl; + mds_lock.Lock(); + suicide(); + mds_lock.Unlock(); + return r; + } + while (monc->wait_auth_rotating(30.0) < 0) { + derr << "unable to obtain rotating service keys; retrying" << dendl; + } objecter->init_unlocked(); mds_lock.Lock(); @@ -1562,7 +1571,8 @@ void MDS::suicide() // shut down cache mdcache->shutdown(); - objecter->shutdown_locked(); + if (objecter->initialized) + objecter->shutdown_locked(); // shut down messenger messenger->shutdown(); |