etcdserver: populate ResponseHeader in Alarm method (#11600)

When no Alarms are found, the response has no header. The header should always
be populated. Some components, like fields printer used by etcdctl, break when
the header is not populated.

Fixes #11581

Signed-off-by: Daniel Lipovetsky <dlipovetsky@d2iq.com>
release-3.5
Daniel Lipovetsky 2020-02-08 23:07:58 -08:00 committed by GitHub
parent 4e5314e9b5
commit bc4adb8b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -169,7 +169,15 @@ func (ms *maintenanceServer) HashKV(ctx context.Context, r *pb.HashKVRequest) (*
}
func (ms *maintenanceServer) Alarm(ctx context.Context, ar *pb.AlarmRequest) (*pb.AlarmResponse, error) {
return ms.a.Alarm(ctx, ar)
resp, err := ms.a.Alarm(ctx, ar)
if err != nil {
return nil, togRPCError(err)
}
if resp.Header == nil {
resp.Header = &pb.ResponseHeader{}
}
ms.hdr.fill(resp.Header)
return resp, nil
}
func (ms *maintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (*pb.StatusResponse, error) {