From 32d1fd3f7e3101204351a45ccfe78baa9e5a5e68 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 9 Jun 2017 17:02:08 -0400 Subject: [PATCH] mon: move pool quota health warnings into PGMap This puts them on the mgr in a context where they can respond to both osdmap and pgmap updates, and removes one more dependency on pgservice in osdmon. We keep the pool quota FULL warning since that is a function of OSDMap state (the pool flag... not actual usage). Signed-off-by: Sage Weil --- src/mon/OSDMonitor.cc | 96 +++++-------------------------------------- src/mon/OSDMonitor.h | 2 - src/mon/PGMap.cc | 65 ++++++++++++++++++++++++++++- 3 files changed, 75 insertions(+), 88 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 05177b1f71e..a22fd324495 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3776,7 +3776,17 @@ void OSDMonitor::get_health(list >& summary, } } - get_pools_health(summary, detail); + for (auto it : osdmap.get_pools()) { + const pg_pool_t &pool = it.second; + if (pool.has_flag(pg_pool_t::FLAG_FULL)) { + const string& pool_name = osdmap.get_pool_name(it.first); + stringstream ss; + ss << "pool '" << pool_name << "' is full"; + summary.push_back(make_pair(HEALTH_WARN, ss.str())); + if (detail) + detail->push_back(make_pair(HEALTH_WARN, ss.str())); + } + } } } @@ -5038,90 +5048,6 @@ bool OSDMonitor::update_pools_status() return ret; } -void OSDMonitor::get_pools_health( - list >& summary, - list > *detail) const -{ - auto& pools = osdmap.get_pools(); - for (auto it = pools.begin(); it != pools.end(); ++it) { - const pool_stat_t *pstat = mon->pgservice->get_pool_stat(it->first); - if (!pstat) - continue; - const object_stat_sum_t& sum = pstat->stats.sum; - const pg_pool_t &pool = it->second; - const string& pool_name = osdmap.get_pool_name(it->first); - - if (pool.has_flag(pg_pool_t::FLAG_FULL)) { - // uncomment these asserts if/when we update the FULL flag on pg_stat update - //assert((pool.quota_max_objects > 0) || (pool.quota_max_bytes > 0)); - - stringstream ss; - ss << "pool '" << pool_name << "' is full"; - summary.push_back(make_pair(HEALTH_WARN, ss.str())); - if (detail) - detail->push_back(make_pair(HEALTH_WARN, ss.str())); - } - - float warn_threshold = (float)g_conf->mon_pool_quota_warn_threshold/100; - float crit_threshold = (float)g_conf->mon_pool_quota_crit_threshold/100; - - if (pool.quota_max_objects > 0) { - stringstream ss; - health_status_t status = HEALTH_OK; - if ((uint64_t)sum.num_objects >= pool.quota_max_objects) { - // uncomment these asserts if/when we update the FULL flag on pg_stat update - //assert(pool.has_flag(pg_pool_t::FLAG_FULL)); - } else if (crit_threshold > 0 && - sum.num_objects >= pool.quota_max_objects*crit_threshold) { - ss << "pool '" << pool_name - << "' has " << sum.num_objects << " objects" - << " (max " << pool.quota_max_objects << ")"; - status = HEALTH_ERR; - } else if (warn_threshold > 0 && - sum.num_objects >= pool.quota_max_objects*warn_threshold) { - ss << "pool '" << pool_name - << "' has " << sum.num_objects << " objects" - << " (max " << pool.quota_max_objects << ")"; - status = HEALTH_WARN; - } - if (status != HEALTH_OK) { - pair s(status, ss.str()); - summary.push_back(s); - if (detail) - detail->push_back(s); - } - } - - if (pool.quota_max_bytes > 0) { - health_status_t status = HEALTH_OK; - stringstream ss; - if ((uint64_t)sum.num_bytes >= pool.quota_max_bytes) { - // uncomment these asserts if/when we update the FULL flag on pg_stat update - //assert(pool.has_flag(pg_pool_t::FLAG_FULL)); - } else if (crit_threshold > 0 && - sum.num_bytes >= pool.quota_max_bytes*crit_threshold) { - ss << "pool '" << pool_name - << "' has " << si_t(sum.num_bytes) << " bytes" - << " (max " << si_t(pool.quota_max_bytes) << ")"; - status = HEALTH_ERR; - } else if (warn_threshold > 0 && - sum.num_bytes >= pool.quota_max_bytes*warn_threshold) { - ss << "pool '" << pool_name - << "' has " << si_t(sum.num_bytes) << " bytes" - << " (max " << si_t(pool.quota_max_bytes) << ")"; - status = HEALTH_WARN; - } - if (status != HEALTH_OK) { - pair s(status, ss.str()); - summary.push_back(s); - if (detail) - detail->push_back(s); - } - } - } -} - - int OSDMonitor::prepare_new_pool(MonOpRequestRef op) { op->mark_osdmon_event(__func__); diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 3a9a27f5c37..9a944107970 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -359,8 +359,6 @@ private: void update_pool_flags(int64_t pool_id, uint64_t flags); bool update_pools_status(); - void get_pools_health(list >& summary, - list > *detail) const; bool prepare_set_flag(MonOpRequestRef op, int flag); bool prepare_unset_flag(MonOpRequestRef op, int flag); diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 88add444b75..9d2e82626a2 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -2548,7 +2548,6 @@ namespace { ss << pgs_count << " unscrubbed pgs"; summary.push_back(make_pair(HEALTH_WARN, ss.str())); } - } } @@ -2938,6 +2937,70 @@ void PGMap::get_health( } } + for (auto it : pools) { + auto it2 = pg_pool_sum.find(it.first); + if (it2 == pg_pool_sum.end()) { + continue; + } + const pool_stat_t *pstat = &it2->second; + const object_stat_sum_t& sum = pstat->stats.sum; + const string& pool_name = osdmap.get_pool_name(it.first); + const pg_pool_t &pool = it.second; + + float warn_threshold = (float)g_conf->mon_pool_quota_warn_threshold/100; + float crit_threshold = (float)g_conf->mon_pool_quota_crit_threshold/100; + + if (pool.quota_max_objects > 0) { + stringstream ss; + health_status_t status = HEALTH_OK; + if ((uint64_t)sum.num_objects >= pool.quota_max_objects) { + } else if (crit_threshold > 0 && + sum.num_objects >= pool.quota_max_objects*crit_threshold) { + ss << "pool '" << pool_name + << "' has " << sum.num_objects << " objects" + << " (max " << pool.quota_max_objects << ")"; + status = HEALTH_ERR; + } else if (warn_threshold > 0 && + sum.num_objects >= pool.quota_max_objects*warn_threshold) { + ss << "pool '" << pool_name + << "' has " << sum.num_objects << " objects" + << " (max " << pool.quota_max_objects << ")"; + status = HEALTH_WARN; + } + if (status != HEALTH_OK) { + pair s(status, ss.str()); + summary.push_back(s); + if (detail) + detail->push_back(s); + } + } + + if (pool.quota_max_bytes > 0) { + health_status_t status = HEALTH_OK; + stringstream ss; + if ((uint64_t)sum.num_bytes >= pool.quota_max_bytes) { + } else if (crit_threshold > 0 && + sum.num_bytes >= pool.quota_max_bytes*crit_threshold) { + ss << "pool '" << pool_name + << "' has " << si_t(sum.num_bytes) << " bytes" + << " (max " << si_t(pool.quota_max_bytes) << ")"; + status = HEALTH_ERR; + } else if (warn_threshold > 0 && + sum.num_bytes >= pool.quota_max_bytes*warn_threshold) { + ss << "pool '" << pool_name + << "' has " << si_t(sum.num_bytes) << " bytes" + << " (max " << si_t(pool.quota_max_bytes) << ")"; + status = HEALTH_WARN; + } + if (status != HEALTH_OK) { + pair s(status, ss.str()); + summary.push_back(s); + if (detail) + detail->push_back(s); + } + } + } + print_unscrubbed_pgs(pg_stat, summary, detail, cct); } -- 2.39.5