Skip to content

Commit

Permalink
Merge pull request #16755 from Juneezee/redundant-len-check
Browse files Browse the repository at this point in the history
etcdserver: remove redundant `len` check in health check
  • Loading branch information
ahrtr authored Oct 13, 2023
2 parents d0d0c33 + 867faa1 commit 3eca40d
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions server/etcdserver/api/etcdhttp/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,25 @@ func getSerializableFlag(r *http.Request) bool {

func checkAlarms(lg *zap.Logger, srv ServerHealth, excludedAlarms AlarmSet) Health {
h := Health{Health: "true"}
as := srv.Alarms()
if len(as) > 0 {
for _, v := range as {
alarmName := v.Alarm.String()
if _, found := excludedAlarms[alarmName]; found {
lg.Debug("/health excluded alarm", zap.String("alarm", v.String()))
continue
}

h.Health = "false"
switch v.Alarm {
case pb.AlarmType_NOSPACE:
h.Reason = "ALARM NOSPACE"
case pb.AlarmType_CORRUPT:
h.Reason = "ALARM CORRUPT"
default:
h.Reason = "ALARM UNKNOWN"
}
lg.Warn("serving /health false due to an alarm", zap.String("alarm", v.String()))
return h
for _, v := range srv.Alarms() {
alarmName := v.Alarm.String()
if _, found := excludedAlarms[alarmName]; found {
lg.Debug("/health excluded alarm", zap.String("alarm", v.String()))
continue
}

h.Health = "false"
switch v.Alarm {
case pb.AlarmType_NOSPACE:
h.Reason = "ALARM NOSPACE"
case pb.AlarmType_CORRUPT:
h.Reason = "ALARM CORRUPT"
default:
h.Reason = "ALARM UNKNOWN"
}
lg.Warn("serving /health false due to an alarm", zap.String("alarm", v.String()))
return h
}

return h
Expand Down

0 comments on commit 3eca40d

Please sign in to comment.