From: Sage Weil Date: Fri, 25 Aug 2017 22:38:49 +0000 (-0400) Subject: mon: remove OldHealthMonitor X-Git-Tag: v13.0.1~1005^2~34 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7b4a741fbda4dc817a003c694e96c8df7c1d2092;p=ceph.git mon: remove OldHealthMonitor The only service this provided was mon space notifications, which are now handled explicitly by the new HealthMonitor's check_member_health(), and communited by the new MMonHealthChecks. Signed-off-by: Sage Weil --- diff --git a/src/messages/MMonHealth.h b/src/messages/MMonHealth.h deleted file mode 100644 index d78e63c6b892c..0000000000000 --- a/src/messages/MMonHealth.h +++ /dev/null @@ -1,85 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2012 Inktank, Inc. - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ -#ifndef CEPH_MMON_HEALTH_H -#define CEPH_MMON_HEALTH_H - -#include "msg/Message.h" -#include "messages/MMonQuorumService.h" -#include "mon/mon_types.h" - -struct MMonHealth : public MMonQuorumService -{ - static const int HEAD_VERSION = 1; - - enum { - OP_TELL = 1, - }; - - int service_type = 0; - int service_op = 0; - - // service specific data - DataStats data_stats; - - MMonHealth() : MMonQuorumService(MSG_MON_HEALTH, HEAD_VERSION) { } - MMonHealth(uint32_t type, int op = 0) : - MMonQuorumService(MSG_MON_HEALTH, HEAD_VERSION), - service_type(type), - service_op(op) - { } - -private: - ~MMonHealth() override { } - -public: - const char *get_type_name() const override { return "mon_health"; } - const char *get_service_op_name() const { - switch (service_op) { - case OP_TELL: return "tell"; - } - return "???"; - } - void print(ostream &o) const override { - o << "mon_health( service " << get_service_type() - << " op " << get_service_op_name() - << " e " << get_epoch() << " r " << get_round() - << " )"; - } - - int get_service_type() const { - return service_type; - } - - int get_service_op() { - return service_op; - } - - void decode_payload() override { - bufferlist::iterator p = payload.begin(); - service_decode(p); - ::decode(service_type, p); - ::decode(service_op, p); - ::decode(data_stats, p); - } - - void encode_payload(uint64_t features) override { - service_encode(); - ::encode(service_type, payload); - ::encode(service_op, payload); - ::encode(data_stats, payload); - } - -}; - -#endif /* CEPH_MMON_HEALTH_H */ diff --git a/src/mon/CMakeLists.txt b/src/mon/CMakeLists.txt index 04044543c21bb..d41ef85fdeb5f 100644 --- a/src/mon/CMakeLists.txt +++ b/src/mon/CMakeLists.txt @@ -16,8 +16,6 @@ set(lib_mon_srcs AuthMonitor.cc Elector.cc HealthMonitor.cc - OldHealthMonitor.cc - DataHealthService.cc PGMonitor.cc PGMap.cc ConfigKeyService.cc diff --git a/src/mon/DataHealthService.cc b/src/mon/DataHealthService.cc deleted file mode 100644 index 236851473c35f..0000000000000 --- a/src/mon/DataHealthService.cc +++ /dev/null @@ -1,196 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2013 Inktank, Inc - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ -#include "include/memory.h" -#include -#include -#include -#include -#include - -#include "acconfig.h" - -#ifdef HAVE_SYS_VFS_H -#include -#endif - -#ifdef HAVE_SYS_MOUNT_H -#include -#endif - -#ifdef HAVE_SYS_PARAM_H -#include -#endif - -#include "messages/MMonHealth.h" -#include "include/assert.h" -#include "common/Formatter.h" -#include "common/errno.h" - -#include "mon/Monitor.h" -#include "mon/DataHealthService.h" - -#define dout_subsys ceph_subsys_mon -#undef dout_prefix -#define dout_prefix _prefix(_dout, mon, this) -static ostream& _prefix(std::ostream *_dout, const Monitor *mon, - const DataHealthService *svc) { - assert(mon != NULL); - assert(svc != NULL); - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() << ")." << svc->get_name() - << "(" << svc->get_epoch() << ") "; -} - -void DataHealthService::start_epoch() -{ - dout(10) << __func__ << " epoch " << get_epoch() << dendl; - // we are not bound by election epochs, but we should clear the stats - // everytime an election is triggerd. As far as we know, a monitor might - // have been running out of disk space and someone fixed it. We don't want - // to hold the cluster back, even confusing the user, due to some possibly - // outdated stats. - stats.clear(); - last_warned_percent = 0; -} - -int DataHealthService::update_store_stats(DataStats &ours) -{ - map extra; - uint64_t store_size = mon->store->get_estimated_size(extra); - assert(store_size > 0); - - ours.store_stats.bytes_total = store_size; - ours.store_stats.bytes_sst = extra["sst"]; - ours.store_stats.bytes_log = extra["log"]; - ours.store_stats.bytes_misc = extra["misc"]; - ours.last_update = ceph_clock_now(); - - return 0; -} - - -int DataHealthService::update_stats() -{ - entity_inst_t our_inst = mon->messenger->get_myinst(); - DataStats& ours = stats[our_inst]; - - int err = get_fs_stats(ours.fs_stats, g_conf->mon_data.c_str()); - if (err < 0) { - derr << __func__ << " get_fs_stats error: " << cpp_strerror(err) << dendl; - return err; - } - dout(0) << __func__ << " avail " << ours.fs_stats.avail_percent << "%" - << " total " << prettybyte_t(ours.fs_stats.byte_total) - << ", used " << prettybyte_t(ours.fs_stats.byte_used) - << ", avail " << prettybyte_t(ours.fs_stats.byte_avail) << dendl; - ours.last_update = ceph_clock_now(); - - return update_store_stats(ours); -} - -void DataHealthService::share_stats() -{ - dout(10) << __func__ << dendl; - if (!in_quorum()) - return; - - assert(!stats.empty()); - entity_inst_t our_inst = mon->messenger->get_myinst(); - assert(stats.count(our_inst) > 0); - DataStats &ours = stats[our_inst]; - const set& quorum = mon->get_quorum(); - for (set::const_iterator it = quorum.begin(); - it != quorum.end(); ++it) { - if (mon->monmap->get_name(*it) == mon->name) - continue; - entity_inst_t inst = mon->monmap->get_inst(*it); - MMonHealth *m = new MMonHealth(HealthService::SERVICE_HEALTH_DATA, - MMonHealth::OP_TELL); - m->data_stats = ours; - dout(20) << __func__ << " send " << *m << " to " << inst << dendl; - mon->messenger->send_message(m, inst); - } -} - -void DataHealthService::service_tick() -{ - dout(10) << __func__ << dendl; - - int err = update_stats(); - if (err < 0) { - derr << "something went wrong obtaining our disk stats: " - << cpp_strerror(err) << dendl; - force_shutdown(); - return; - } - if (in_quorum()) - share_stats(); - - DataStats &ours = stats[mon->messenger->get_myinst()]; - - if (ours.fs_stats.avail_percent <= g_conf->mon_data_avail_crit) { - derr << "reached critical levels of available space on local monitor storage" - << " -- shutdown!" << dendl; - force_shutdown(); - return; - } - - // we must backoff these warnings, and track how much data is being - // consumed in-between reports to assess if it's worth to log this info, - // otherwise we may very well contribute to the consumption of the - // already low available disk space. - if (ours.fs_stats.avail_percent <= g_conf->mon_data_avail_warn) { - if (ours.fs_stats.avail_percent != last_warned_percent) - mon->clog->warn() - << "reached concerning levels of available space on local monitor storage" - << " (" << ours.fs_stats.avail_percent << "% free)"; - last_warned_percent = ours.fs_stats.avail_percent; - } else { - last_warned_percent = 0; - } -} - -void DataHealthService::handle_tell(MonOpRequestRef op) -{ - op->mark_event("datahealth:handle_tell"); - MMonHealth *m = static_cast(op->get_req()); - dout(10) << __func__ << " " << *m << dendl; - assert(m->get_service_op() == MMonHealth::OP_TELL); - - stats[m->get_source_inst()] = m->data_stats; -} - -bool DataHealthService::service_dispatch_op(MonOpRequestRef op) -{ - op->mark_event("datahealth:service_dispatch_op"); - MMonHealth *m = static_cast(op->get_req()); - dout(10) << __func__ << " " << *m << dendl; - assert(m->get_service_type() == get_type()); - if (!in_quorum()) { - dout(1) << __func__ << " not in quorum -- drop message" << dendl; - return false; - } - - switch (m->service_op) { - case MMonHealth::OP_TELL: - // someone is telling us their stats - handle_tell(op); - break; - default: - dout(0) << __func__ << " unknown op " << m->service_op << dendl; - assert(0 == "Unknown service op"); - break; - } - return true; -} diff --git a/src/mon/DataHealthService.h b/src/mon/DataHealthService.h deleted file mode 100644 index 3dfcd54db075f..0000000000000 --- a/src/mon/DataHealthService.h +++ /dev/null @@ -1,77 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2013 Inktank, Inc - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ -#ifndef CEPH_MON_DATA_HEALTH_SERVICE_H -#define CEPH_MON_DATA_HEALTH_SERVICE_H - -#include - -#include "include/types.h" -#include "mon/mon_types.h" -#include "mon/HealthService.h" -#include "common/config.h" -#include "global/signal_handler.h" - -struct MMonHealth; -namespace ceph { class Formatter; } - - -class DataHealthService : - public HealthService -{ - map stats; - int last_warned_percent; - - void handle_tell(MonOpRequestRef op); - int update_store_stats(DataStats &ours); - int update_stats(); - void share_stats(); - - void force_shutdown() { - generic_dout(0) << "** Shutdown via Data Health Service **" << dendl; - queue_async_signal(SIGINT); - } - -protected: - void service_tick() override; - bool service_dispatch_op(MonOpRequestRef op) override; - void service_shutdown() override { } - - void start_epoch() override; - void finish_epoch() override { } - void cleanup() override { } - -public: - DataHealthService(Monitor *m) : - HealthService(m), - last_warned_percent(0) - { - set_update_period(g_conf->mon_health_data_update_interval); - } - ~DataHealthService() override { } - - void init() override { - generic_dout(20) << "data_health " << __func__ << dendl; - start_tick(); - } - - int get_type() override { - return HealthService::SERVICE_HEALTH_DATA; - } - - string get_name() const override { - return "data_health"; - } -}; - -#endif /* CEPH_MON_DATA_HEALTH_SERVICE_H */ diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index e9e5ad3aa4a23..53c9999e753dd 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -23,9 +23,7 @@ #include "mon/Monitor.h" #include "mon/HealthService.h" #include "mon/HealthMonitor.h" -#include "mon/DataHealthService.h" -#include "messages/MMonHealth.h" #include "messages/MMonHealthChecks.h" #include "common/Formatter.h" @@ -162,17 +160,6 @@ bool HealthMonitor::prepare_update(MonOpRequestRef op) dout(7) << "prepare_update " << *m << " from " << m->get_orig_source_inst() << dendl; switch (m->get_type()) { - case MSG_MON_HEALTH: - { - MMonHealth *hm = static_cast(op->get_req()); - int service_type = hm->get_service_type(); - if (services.count(service_type) == 0) { - dout(1) << __func__ << " service type " << service_type - << " not registered -- drop message!" << dendl; - return false; - } - return services[service_type]->service_dispatch(op); - } case MSG_MON_HEALTH_CHECKS: return prepare_health_checks(op); default: diff --git a/src/mon/HealthMonitor.h b/src/mon/HealthMonitor.h index ca9e083c8de3c..073a4e68c5915 100644 --- a/src/mon/HealthMonitor.h +++ b/src/mon/HealthMonitor.h @@ -18,20 +18,15 @@ //forward declaration namespace ceph { class Formatter; } -class HealthService; class HealthMonitor : public PaxosService { - map services; version_t version = 0; map quorum_checks; // for each quorum member health_check_map_t leader_checks; // leader only public: HealthMonitor(Monitor *m, Paxos *p, const string& service_name); - ~HealthMonitor() override { - assert(services.empty()); - } /** * @defgroup HealthMonitor_Inherited_h Inherited abstract methods diff --git a/src/mon/HealthService.h b/src/mon/HealthService.h index 29ff57dcb46b4..75588cf6f5192 100644 --- a/src/mon/HealthService.h +++ b/src/mon/HealthService.h @@ -17,8 +17,6 @@ #include "mon/Monitor.h" #include "mon/QuorumService.h" -#include "messages/MMonHealth.h" - #include "common/config.h" struct HealthService : public QuorumService diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index cd5fcc81228ab..1712ffd5f4186 100755 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -36,7 +36,6 @@ #include "messages/MGenericMessage.h" #include "messages/MMonCommand.h" #include "messages/MMonCommandAck.h" -#include "messages/MMonHealth.h" #include "messages/MMonMetadata.h" #include "messages/MMonSync.h" #include "messages/MMonScrub.h" @@ -77,7 +76,6 @@ #include "MgrMonitor.h" #include "MgrStatMonitor.h" #include "mon/QuorumService.h" -#include "mon/OldHealthMonitor.h" #include "mon/HealthMonitor.h" #include "mon/ConfigKeyService.h" #include "common/config.h" @@ -197,7 +195,6 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s, paxos_service[PAXOS_MGRSTAT] = new MgrStatMonitor(this, paxos, "mgrstat"); paxos_service[PAXOS_HEALTH] = new HealthMonitor(this, paxos, "health"); - health_monitor = new OldHealthMonitor(this); config_key_service = new ConfigKeyService(this, paxos); mon_caps = new MonCap(); @@ -234,7 +231,6 @@ Monitor::~Monitor() { for (vector::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p) delete *p; - delete health_monitor; delete config_key_service; delete paxos; assert(session_map.sessions.empty()); @@ -685,7 +681,6 @@ int Monitor::preinit() dout(10) << "sync_last_committed_floor " << sync_last_committed_floor << dendl; init_paxos(); - health_monitor->init(); if (is_keyring_required()) { // we need to bootstrap authentication keys so we can form an @@ -910,7 +905,6 @@ void Monitor::shutdown() paxos->shutdown(); for (vector::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p) (*p)->shutdown(); - health_monitor->shutdown(); finish_contexts(g_ceph_context, waitfor_quorum, -ECANCELED); finish_contexts(g_ceph_context, maybe_wait_for_quorum, -ECANCELED); @@ -1079,7 +1073,6 @@ void Monitor::_reset() for (vector::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p) (*p)->restart(); - health_monitor->finish(); } @@ -1934,7 +1927,6 @@ void Monitor::win_election(epoch_t epoch, set& active, uint64_t features, // round without agreeing on who the participants are. monmon()->election_finished(); _finish_svc_election(); - health_monitor->start(epoch); logger->inc(l_mon_election_win); @@ -1987,7 +1979,6 @@ void Monitor::lose_election(epoch_t epoch, set &q, int l, paxos->peon_init(); _finish_svc_election(); - health_monitor->start(epoch); logger->inc(l_mon_election_lose); @@ -4264,10 +4255,6 @@ void Monitor::dispatch_op(MonOpRequestRef op) handle_timecheck(op); break; - case MSG_MON_HEALTH: - health_monitor->dispatch(op); - break; - case MSG_MON_HEALTH_CHECKS: op->set_type_service(); paxos_service[PAXOS_HEALTH]->dispatch(op); diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 548953104b3bd..51dcb5f552288 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -662,7 +662,6 @@ public: friend class LogMonitor; friend class ConfigKeyService; - QuorumService *health_monitor; QuorumService *config_key_service; // -- sessions -- diff --git a/src/mon/OldHealthMonitor.cc b/src/mon/OldHealthMonitor.cc deleted file mode 100644 index dac93f8ebee91..0000000000000 --- a/src/mon/OldHealthMonitor.cc +++ /dev/null @@ -1,97 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2013 Inktank, Inc - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#include -#include -#include - -// #include -// Because intusive_ptr clobbers our assert... -#include "include/assert.h" - -#include "mon/Monitor.h" -#include "mon/HealthService.h" -#include "mon/OldHealthMonitor.h" -#include "mon/DataHealthService.h" - -#include "messages/MMonHealth.h" -#include "common/Formatter.h" -// #include "common/config.h" - -#define dout_subsys ceph_subsys_mon -#undef dout_prefix -#define dout_prefix _prefix(_dout, mon, this) -static ostream& _prefix(std::ostream *_dout, const Monitor *mon, - const OldHealthMonitor *hmon) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() << ")." << hmon->get_name() - << "(" << hmon->get_epoch() << ") "; -} - -void OldHealthMonitor::init() -{ - dout(10) << __func__ << dendl; - assert(services.empty()); - services[HealthService::SERVICE_HEALTH_DATA] = new DataHealthService(mon); - - for (map::iterator it = services.begin(); - it != services.end(); - ++it) { - it->second->init(); - } -} - -bool OldHealthMonitor::service_dispatch(MonOpRequestRef op) -{ - assert(op->get_req()->get_type() == MSG_MON_HEALTH); - MMonHealth *hm = static_cast(op->get_req()); - int service_type = hm->get_service_type(); - if (services.count(service_type) == 0) { - dout(1) << __func__ << " service type " << service_type - << " not registered -- drop message!" << dendl; - return false; - } - return services[service_type]->service_dispatch(op); -} - -void OldHealthMonitor::start_epoch() { - epoch_t epoch = get_epoch(); - for (map::iterator it = services.begin(); - it != services.end(); ++it) { - it->second->start(epoch); - } -} - -void OldHealthMonitor::finish_epoch() { - generic_dout(20) << "OldHealthMonitor::finish_epoch()" << dendl; - for (map::iterator it = services.begin(); - it != services.end(); ++it) { - assert(it->second != NULL); - it->second->finish(); - } -} - -void OldHealthMonitor::service_shutdown() -{ - dout(0) << "OldHealthMonitor::service_shutdown " - << services.size() << " services" << dendl; - for (map::iterator it = services.begin(); - it != services.end(); - ++it) { - it->second->shutdown(); - delete it->second; - } - services.clear(); -} - diff --git a/src/mon/OldHealthMonitor.h b/src/mon/OldHealthMonitor.h deleted file mode 100644 index b1e6eea72b0e9..0000000000000 --- a/src/mon/OldHealthMonitor.h +++ /dev/null @@ -1,64 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2013 Inktank, Inc - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ -#ifndef CEPH_MON_OLDHEALTHMONITOR_H -#define CEPH_MON_OLDHEALTHMONITOR_H - -#include "mon/QuorumService.h" - -//forward declaration -namespace ceph { class Formatter; } -class HealthService; - -class OldHealthMonitor : public QuorumService -{ - map services; - -protected: - void service_shutdown() override; - -public: - OldHealthMonitor(Monitor *m) : QuorumService(m) { } - ~OldHealthMonitor() override { - assert(services.empty()); - } - - - /** - * @defgroup OldHealthMonitor_Inherited_h Inherited abstract methods - * @{ - */ - void init() override; - bool service_dispatch(MonOpRequestRef op) override; - - void start_epoch() override; - - void finish_epoch() override; - - void cleanup() override { } - void service_tick() override { } - - int get_type() override { - return QuorumService::SERVICE_HEALTH; - } - - string get_name() const override { - return "health"; - } - - /** - * @} // OldHealthMonitor_Inherited_h - */ -}; - -#endif diff --git a/src/msg/Message.cc b/src/msg/Message.cc index e231b65ed73fb..fb30526e48ab8 100644 --- a/src/msg/Message.cc +++ b/src/msg/Message.cc @@ -96,7 +96,6 @@ using namespace std; #include "messages/MMonGetMap.h" #include "messages/MMonGetVersion.h" #include "messages/MMonGetVersionReply.h" -#include "messages/MMonHealth.h" #include "messages/MMonHealthChecks.h" #include "messages/MMonMetadata.h" #include "messages/MDataPing.h" @@ -785,10 +784,6 @@ Message *decode_message(CephContext *cct, int crcflags, m = new MTimeCheck(); break; - case MSG_MON_HEALTH: - m = new MMonHealth(); - break; - case MSG_MON_HEALTH_CHECKS: m = new MMonHealthChecks(); break; diff --git a/src/msg/Message.h b/src/msg/Message.h index 091b07d6ee217..b19991d1cecb7 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -172,7 +172,7 @@ // *** generic *** #define MSG_TIMECHECK 0x600 -#define MSG_MON_HEALTH 0x601 +//#define MSG_MON_HEALTH 0x601 // remove post-luminous // *** Message::encode() crcflags bits *** #define MSG_CRC_DATA (1 << 0)