From 80942eb04ca75f40234a5b671827bc7e8aa27439 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 27 May 2013 15:27:59 -0700 Subject: osd: move health checks into a single helper For now we still only look at the internal heartbeats. Signed-off-by: Sage Weil --- src/osd/OSD.cc | 16 +++++++++++++--- src/osd/OSD.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 5aad94c272e..4bbcd06243e 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2679,7 +2679,7 @@ void OSD::tick() logger->set(l_osd_buf, buffer::get_total_alloc()); if (is_waiting_for_healthy()) { - if (g_ceph_context->get_heartbeat_map()->is_healthy()) { + if (_is_healthy()) { dout(1) << "healthy again, booting" << dendl; state = STATE_BOOTING; start_boot(); @@ -3062,9 +3062,9 @@ void OSD::_maybe_boot(epoch_t oldest, epoch_t newest) // if our map within recent history, try to add ourselves to the osdmap. if (osdmap->test_flag(CEPH_OSDMAP_NOUP)) { dout(5) << "osdmap NOUP flag is set, waiting for it to clear" << dendl; - } else if (!g_ceph_context->get_heartbeat_map()->is_healthy()) { + } else if (!_is_healthy()) { // if we are not healthy, do not mark ourselves up (yet) - dout(1) << "internal heartbeats indicate we are not healthy; waiting to boot" << dendl; + dout(1) << "not healthy; waiting to boot" << dendl; state = STATE_WAITING_FOR_HEALTHY; } else if (osdmap->get_epoch() >= oldest - 1 && osdmap->get_epoch() + g_conf->osd_map_message_max > newest) { @@ -3080,6 +3080,16 @@ void OSD::_maybe_boot(epoch_t oldest, epoch_t newest) monc->renew_subs(); } +bool OSD::_is_healthy() +{ + if (!g_ceph_context->get_heartbeat_map()->is_healthy()) { + dout(1) << "is_healthy false -- internal heartbeat failed" << dendl; + return false; + } + + return true; +} + void OSD::_send_boot() { dout(10) << "_send_boot" << dendl; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 99d75dc40ad..978749d1a7e 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1116,6 +1116,7 @@ protected: void start_boot(); void _maybe_boot(epoch_t oldest, epoch_t newest); void _send_boot(); + bool _is_healthy(); friend class C_OSD_GetVersion; -- cgit v1.2.1