mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
v3rpc: clean up "maintenanceServer.Status" call
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
c22afc2d71
commit
4cb0d167d6
@ -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) {
|
||||
hdr := &pb.ResponseHeader{}
|
||||
ms.hdr.fill(hdr)
|
||||
resp := &pb.StatusResponse{
|
||||
Header: &pb.ResponseHeader{Revision: ms.hdr.rev()},
|
||||
Header: hdr,
|
||||
Version: version.Version,
|
||||
DbSize: ms.bg.Backend().Size(),
|
||||
Leader: uint64(ms.rg.Leader()),
|
||||
RaftIndex: ms.rg.CommittedIndex(),
|
||||
RaftAppliedIndex: ms.rg.AppliedIndex(),
|
||||
RaftTerm: ms.rg.Term(),
|
||||
DbSize: ms.bg.Backend().Size(),
|
||||
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())
|
||||
}
|
||||
alarms := ms.a.Alarms()
|
||||
if len(alarms) > 0 {
|
||||
for _, alarm := range alarms {
|
||||
resp.Errors = append(resp.Errors, alarm.String())
|
||||
}
|
||||
for _, a := range ms.a.Alarms() {
|
||||
resp.Errors = append(resp.Errors, a.String())
|
||||
}
|
||||
ms.hdr.fill(resp.Header)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user