etcdserver: check alarms in health handler

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyu-Ho Lee 2017-07-17 15:29:44 -07:00
parent d8481c9fda
commit 61a736a068
2 changed files with 8 additions and 0 deletions

View File

@ -67,6 +67,10 @@ func healthHandler(server *etcdserver.EtcdServer) http.HandlerFunc {
http.Error(w, `{"health": "false"}`, http.StatusServiceUnavailable)
return
}
if len(server.Alarms()) > 0 {
w.Write([]byte(`{"health": "false"}`))
return
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
if _, err := server.Do(ctx, etcdserverpb.Request{Method: "QGET"}); err != nil {

View File

@ -1667,3 +1667,7 @@ func (s *EtcdServer) goAttach(f func()) {
f()
}()
}
func (s *EtcdServer) Alarms() []*pb.AlarmMember {
return s.alarmStore.Get(pb.AlarmType_NONE)
}