Skip to content

Commit

Permalink
Merge pull request #14537 from ahrtr/add_hash_rev
Browse files Browse the repository at this point in the history
Add a new field hash_revision into HashKVResponse
  • Loading branch information
ahrtr authored Nov 14, 2022
2 parents 4c82446 + f77b8a7 commit 3cf2e79
Show file tree
Hide file tree
Showing 6 changed files with 330 additions and 279 deletions.
5 changes: 5 additions & 0 deletions Documentation/dev-guide/apispec/swagger/rpc.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2123,6 +2123,11 @@
"type": "integer",
"format": "int64"
},
"hash_revision": {
"description": "hash_revision is the revision up to which the hash is calculated.",
"type": "string",
"format": "int64"
},
"header": {
"$ref": "#/definitions/etcdserverpbResponseHeader"
}
Expand Down
593 changes: 315 additions & 278 deletions api/etcdserverpb/rpc.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions api/etcdserverpb/rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ message HashKVResponse {
uint32 hash = 2;
// compact_revision is the compacted revision of key-value store when hash begins.
int64 compact_revision = 3;
// hash_revision is the revision up to which the hash is calculated.
int64 hash_revision = 4 [(versionpb.etcd_version_field)="3.6"];
}

message HashResponse {
Expand Down
1 change: 1 addition & 0 deletions scripts/etcd_version_annotations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ etcdserverpb.HashKVRequest.revision: ""
etcdserverpb.HashKVResponse: "3.3"
etcdserverpb.HashKVResponse.compact_revision: ""
etcdserverpb.HashKVResponse.hash: ""
etcdserverpb.HashKVResponse.hash_revision: "3.6"
etcdserverpb.HashKVResponse.header: ""
etcdserverpb.HashRequest: "3.0"
etcdserverpb.HashResponse: "3.0"
Expand Down
7 changes: 6 additions & 1 deletion server/etcdserver/api/v3rpc/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ func (ms *maintenanceServer) HashKV(ctx context.Context, r *pb.HashKVRequest) (*
return nil, togRPCError(err)
}

resp := &pb.HashKVResponse{Header: &pb.ResponseHeader{Revision: rev}, Hash: h.Hash, CompactRevision: h.CompactRevision}
resp := &pb.HashKVResponse{
Header: &pb.ResponseHeader{Revision: rev},
Hash: h.Hash,
CompactRevision: h.CompactRevision,
HashRevision: h.Revision,
}
ms.hdr.fill(resp.Header)
return resp, nil
}
Expand Down
1 change: 1 addition & 0 deletions server/etcdserver/corrupt.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ func (h *hashKVHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Header: &pb.ResponseHeader{Revision: rev},
Hash: hash.Hash,
CompactRevision: hash.CompactRevision,
HashRevision: hash.Revision,
}
respBytes, err := json.Marshal(resp)
if err != nil {
Expand Down

0 comments on commit 3cf2e79

Please sign in to comment.