Skip to content

Commit

Permalink
etcdserver: check alarms in health handler
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuho committed Jul 17, 2017
1 parent 9ce7bb6 commit 6b6763a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etcdserver/api/etcdhttp/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func healthHandler(server *etcdserver.EtcdServer) http.HandlerFunc {
http.Error(w, `{"health": "false"}`, http.StatusServiceUnavailable)
return
}
if len(server.ListAlarms()) > 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 {
Expand Down
4 changes: 4 additions & 0 deletions etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1667,3 +1667,7 @@ func (s *EtcdServer) goAttach(f func()) {
f()
}()
}

func (s *EtcdServer) ListAlarms() []*pb.AlarmMember {
return s.alarmStore.Get(pb.AlarmType_NONE)
}

0 comments on commit 6b6763a

Please sign in to comment.