summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <joao.luis@inktank.com>2013-04-19 19:26:51 +0100
committerJoao Eduardo Luis <joao.luis@inktank.com>2013-04-19 19:26:51 +0100
commitfa89cfd2e4ccb8a80666ac1c8aeea91717fdb2e9 (patch)
tree90eb4b48c2b91ef0db9bd7a4a25d297e268b2889
parent5e4b8bc4426eeb3879c3c524558c25b7f2c816b8 (diff)
downloadceph-fa89cfd2e4ccb8a80666ac1c8aeea91717fdb2e9.tar.gz
mon: QuorumService: return health status on get_health()
This allows us to return the appropriate overall health status on Monitor::get_health(). Fixes: 4574 Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
-rw-r--r--src/mon/ConfigKeyService.h7
-rw-r--r--src/mon/DataHealthService.cc12
-rw-r--r--src/mon/DataHealthService.h2
-rw-r--r--src/mon/HealthMonitor.cc2
-rw-r--r--src/mon/HealthMonitor.h2
-rw-r--r--src/mon/HealthService.h2
-rw-r--r--src/mon/Monitor.cc8
-rw-r--r--src/mon/QuorumService.h2
8 files changed, 26 insertions, 11 deletions
diff --git a/src/mon/ConfigKeyService.h b/src/mon/ConfigKeyService.h
index aee85bc0859..49e15acdfc6 100644
--- a/src/mon/ConfigKeyService.h
+++ b/src/mon/ConfigKeyService.h
@@ -58,8 +58,11 @@ public:
* @{
*/
virtual void init() { }
- virtual void get_health(Formatter *f,
- list<pair<health_status_t,string> > *detail) { }
+ virtual health_status_t get_health(
+ Formatter *f,
+ list<pair<health_status_t,string> > *detail) {
+ return HEALTH_OK;
+ }
virtual bool service_dispatch(Message *m);
virtual void start_epoch() { }
diff --git a/src/mon/DataHealthService.cc b/src/mon/DataHealthService.cc
index 2410cbc4d68..d1a227fe0fd 100644
--- a/src/mon/DataHealthService.cc
+++ b/src/mon/DataHealthService.cc
@@ -54,8 +54,9 @@ void DataHealthService::start_epoch()
last_warned_percent = 0;
}
-void DataHealthService::get_health(Formatter *f,
- list<pair<health_status_t,string> > *detail)
+health_status_t DataHealthService::get_health(
+ Formatter *f,
+ list<pair<health_status_t,string> > *detail)
{
dout(10) << __func__ << dendl;
assert(f != NULL);
@@ -63,6 +64,8 @@ void DataHealthService::get_health(Formatter *f,
f->open_object_section("data_health");
f->open_array_section("mons");
+ health_status_t overall_status = HEALTH_OK;
+
for (map<entity_inst_t,DataStats>::iterator it = stats.begin();
it != stats.end(); ++it) {
string mon_name = mon->monmap->get_name(it->first.addr);
@@ -78,6 +81,9 @@ void DataHealthService::get_health(Formatter *f,
health_detail = "low disk space!";
}
+ if (overall_status > health_status)
+ overall_status = health_status;
+
if (detail && health_status != HEALTH_OK) {
stringstream ss;
ss << "mon." << mon_name << " addr " << it->first.addr
@@ -101,6 +107,8 @@ void DataHealthService::get_health(Formatter *f,
f->close_section(); // mons
f->close_section(); // data_health
+
+ return overall_status;
}
int DataHealthService::update_stats()
diff --git a/src/mon/DataHealthService.h b/src/mon/DataHealthService.h
index de7ab0ac258..c94327f3129 100644
--- a/src/mon/DataHealthService.h
+++ b/src/mon/DataHealthService.h
@@ -75,7 +75,7 @@ public:
start_tick();
}
- virtual void get_health(Formatter *f,
+ virtual health_status_t get_health(Formatter *f,
list<pair<health_status_t,string> > *detail);
virtual int get_type() {
diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc
index cf3d962b2c4..b62ed7da31e 100644
--- a/src/mon/HealthMonitor.cc
+++ b/src/mon/HealthMonitor.cc
@@ -78,7 +78,7 @@ void HealthMonitor::service_shutdown()
services.clear();
}
-void HealthMonitor::get_health(Formatter *f,
+health_status_t HealthMonitor::get_health(Formatter *f,
list<pair<health_status_t,string> > *detail) {
assert(f != NULL);
f->open_object_section("health");
diff --git a/src/mon/HealthMonitor.h b/src/mon/HealthMonitor.h
index 85581edde9b..e0255d20081 100644
--- a/src/mon/HealthMonitor.h
+++ b/src/mon/HealthMonitor.h
@@ -47,7 +47,7 @@ public:
* @{
*/
virtual void init();
- virtual void get_health(Formatter *f,
+ virtual health_status_t get_health(Formatter *f,
list<pair<health_status_t,string> > *detail);
virtual bool service_dispatch(Message *m);
diff --git a/src/mon/HealthService.h b/src/mon/HealthService.h
index b62ed5991eb..1e041f5739e 100644
--- a/src/mon/HealthService.h
+++ b/src/mon/HealthService.h
@@ -44,7 +44,7 @@ public:
HealthService *get() {
return static_cast<HealthService *>(RefCountedObject::get());
}
- virtual void get_health(Formatter *f,
+ virtual health_status_t get_health(Formatter *f,
list<pair<health_status_t,string> > *detail) = 0;
virtual int get_type() = 0;
virtual string get_name() const = 0;
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index e3d33ce9d60..da6a7e662bd 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -2297,8 +2297,12 @@ void Monitor::get_health(string& status, bufferlist *detailbl, Formatter *f)
if (f)
f->close_section();
- if (f)
- health_monitor->get_health(f, (detailbl ? &detail : NULL));
+ if (f) {
+ health_status_t hmstatus =
+ health_monitor->get_health(f, (detailbl ? &detail : NULL));
+ if (overall > hmstatus)
+ overall = hmstatus;
+ }
stringstream fss;
fss << overall;
diff --git a/src/mon/QuorumService.h b/src/mon/QuorumService.h
index dfa4f4165e9..7506421caf4 100644
--- a/src/mon/QuorumService.h
+++ b/src/mon/QuorumService.h
@@ -133,7 +133,7 @@ public:
virtual void init() { }
- virtual void get_health(Formatter *f,
+ virtual health_status_t get_health(Formatter *f,
list<pair<health_status_t,string> > *detail) = 0;
virtual int get_type() = 0;
virtual string get_name() const = 0;