From: David Zafman Date: Tue, 15 Jan 2019 20:12:39 +0000 (-0800) Subject: mon: Fix scrub health warning handling X-Git-Tag: v12.2.12~39^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d90dee14995392a076a7fc904b0cd058076dc2c3;p=ceph.git mon: Fix scrub health warning handling Make this mon_warn code clearer since it involves 2 values Code used mon scrub interval instead of pg scrub interval Fix scrub warniing handling use per-pool intervals when specified Fixes: http://tracker.ceph.com/issues/37264 Signed-off-by: David Zafman (cherry picked from commit 6a9895b97a2b2fb533092f294e45fede154a7f82) Modified from master to leave config name alone and not to use ratio (cherry picked from commit 5f3dc9b76e971f23625da78a6f05333c621b210e) --- diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index b8b2430cf6d..20c2b09c338 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -3270,24 +3270,28 @@ void PGMap::get_health_checks( // PG_NOT_SCRUBBED // PG_NOT_DEEP_SCRUBBED - { - if (cct->_conf->mon_warn_not_scrubbed || + if (cct->_conf->mon_warn_not_scrubbed || cct->_conf->mon_warn_not_deep_scrubbed) { - list detail, deep_detail; - int detail_max = max, deep_detail_max = max; - int detail_more = 0, deep_detail_more = 0; - int detail_total = 0, deep_detail_total = 0; - const double age = cct->_conf->mon_warn_not_scrubbed + - cct->_conf->mon_scrub_interval; - utime_t cutoff = now; - cutoff -= age; - const double deep_age = cct->_conf->mon_warn_not_deep_scrubbed + - cct->_conf->osd_deep_scrub_interval; - utime_t deep_cutoff = now; - deep_cutoff -= deep_age; - for (auto& p : pg_stat) { - if (cct->_conf->mon_warn_not_scrubbed && - p.second.last_scrub_stamp < cutoff) { + list detail, deep_detail; + int detail_max = max, deep_detail_max = max; + int detail_more = 0, deep_detail_more = 0; + int detail_total = 0, deep_detail_total = 0; + for (auto& p : pg_stat) { + int64_t pnum = p.first.pool(); + auto pool = osdmap.get_pg_pool(pnum); + if (!pool) + continue; + if (cct->_conf->mon_warn_not_scrubbed) { + double scrub_max_interval = 0; + pool->opts.get(pool_opts_t::SCRUB_MAX_INTERVAL, &scrub_max_interval); + if (scrub_max_interval <= 0) { + scrub_max_interval = cct->_conf->osd_scrub_max_interval; + } + const double age = cct->_conf->mon_warn_not_scrubbed + + scrub_max_interval; + utime_t cutoff = now; + cutoff -= age; + if (p.second.last_scrub_stamp < cutoff) { if (detail_max > 0) { ostringstream ss; ss << "pg " << p.first << " not scrubbed since " @@ -3299,8 +3303,18 @@ void PGMap::get_health_checks( } ++detail_total; } - if (cct->_conf->mon_warn_not_deep_scrubbed && - p.second.last_deep_scrub_stamp < deep_cutoff) { + } + if (cct->_conf->mon_warn_not_deep_scrubbed) { + double deep_scrub_interval = 0; + pool->opts.get(pool_opts_t::DEEP_SCRUB_INTERVAL, &deep_scrub_interval); + if (deep_scrub_interval <= 0) { + deep_scrub_interval = cct->_conf->osd_deep_scrub_interval; + } + double deep_age = cct->_conf->mon_warn_not_deep_scrubbed + + deep_scrub_interval; + utime_t deep_cutoff = now; + deep_cutoff -= deep_age; + if (p.second.last_deep_scrub_stamp < deep_cutoff) { if (deep_detail_max > 0) { ostringstream ss; ss << "pg " << p.first << " not deep-scrubbed since " @@ -3311,36 +3325,36 @@ void PGMap::get_health_checks( ++deep_detail_more; } ++deep_detail_total; - } + } } - if (detail_total) { - ostringstream ss; - ss << detail_total << " pgs not scrubbed for " << age; - auto& d = checks->add("PG_NOT_SCRUBBED", HEALTH_WARN, ss.str()); + } + if (detail_total) { + ostringstream ss; + ss << detail_total << " pgs not scrubbed in time"; + auto& d = checks->add("PG_NOT_SCRUBBED", HEALTH_WARN, ss.str()); - if (!detail.empty()) { - d.detail.swap(detail); + if (!detail.empty()) { + d.detail.swap(detail); - if (detail_more) { - ostringstream ss; - ss << detail_more << " more pgs... "; - d.detail.push_back(ss.str()); - } + if (detail_more) { + ostringstream ss; + ss << detail_more << " more pgs... "; + d.detail.push_back(ss.str()); } } - if (deep_detail_total) { - ostringstream ss; - ss << deep_detail_total << " pgs not deep-scrubbed for " << deep_age; - auto& d = checks->add("PG_NOT_DEEP_SCRUBBED", HEALTH_WARN, ss.str()); + } + if (deep_detail_total) { + ostringstream ss; + ss << deep_detail_total << " pgs not deep-scrubbed in time"; + auto& d = checks->add("PG_NOT_DEEP_SCRUBBED", HEALTH_WARN, ss.str()); - if (!deep_detail.empty()) { - d.detail.swap(deep_detail); + if (!deep_detail.empty()) { + d.detail.swap(deep_detail); - if (deep_detail_more) { - ostringstream ss; - ss << deep_detail_more << " more pgs... "; - d.detail.push_back(ss.str()); - } + if (deep_detail_more) { + ostringstream ss; + ss << deep_detail_more << " more pgs... "; + d.detail.push_back(ss.str()); } } }