v3rpc: clean up "maintenanceServer.Status" call

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee 2018-03-17 02:41:54 -07:00
parent c22afc2d71
commit 4cb0d167d6

View File

@ -149,26 +149,24 @@ func (ms *maintenanceServer) Alarm(ctx context.Context, ar *pb.AlarmRequest) (*p
} }
func (ms *maintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (*pb.StatusResponse, error) { func (ms *maintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (*pb.StatusResponse, error) {
hdr := &pb.ResponseHeader{}
ms.hdr.fill(hdr)
resp := &pb.StatusResponse{ resp := &pb.StatusResponse{
Header: &pb.ResponseHeader{Revision: ms.hdr.rev()}, Header: hdr,
Version: version.Version, Version: version.Version,
DbSize: ms.bg.Backend().Size(),
Leader: uint64(ms.rg.Leader()), Leader: uint64(ms.rg.Leader()),
RaftIndex: ms.rg.CommittedIndex(), RaftIndex: ms.rg.CommittedIndex(),
RaftAppliedIndex: ms.rg.AppliedIndex(), RaftAppliedIndex: ms.rg.AppliedIndex(),
RaftTerm: ms.rg.Term(), RaftTerm: ms.rg.Term(),
DbSize: ms.bg.Backend().Size(),
DbSizeInUse: ms.bg.Backend().SizeInUse(), DbSizeInUse: ms.bg.Backend().SizeInUse(),
} }
if uint64(ms.rg.Leader()) == raft.None { if resp.Leader == raft.None {
resp.Errors = append(resp.Errors, etcdserver.ErrNoLeader.Error()) resp.Errors = append(resp.Errors, etcdserver.ErrNoLeader.Error())
} }
alarms := ms.a.Alarms() for _, a := range ms.a.Alarms() {
if len(alarms) > 0 { resp.Errors = append(resp.Errors, a.String())
for _, alarm := range alarms {
resp.Errors = append(resp.Errors, alarm.String())
}
} }
ms.hdr.fill(resp.Header)
return resp, nil return resp, nil
} }