grpc-gateway: update version to v1.11.0

The issue is caused by hand-crafted protobuf message. The runtime.errorBody
defines two protobuf fields with same number. We need to upgrade the
version to fix it. Otherwise, the client side won't receive any errors
from server side because of panic.

```
mismatching field: runtime.errorBody.error, want runtime.errorBody.message
```

It can fix the cases

PASSES="build grpcproxy" CPU=4 RACE=true ./test -run TestV3CurlLeaseRevokeNoTLS

The original error is like:

```
v3_curl_lease_test.go:109: testV3CurlLeaseRevoke: prefix (/v3) endpoint (/kv/lease/revoke): error (read /dev/ptmx: input/output error (expected "etcdserver: requested lease not found", got ["curl: (52) Empty reply from server\r\n"])), wanted etcdserver: requested lease not found
    v3_curl_lease_test.go:109: testV3CurlLeaseRevoke: prefix (/v3beta) endpoint (/kv/lease/revoke): error (read /dev/ptmx: input/output error (expected "etcdserver: requested lease not found", got ["curl: (52) Empty reply from server\r\n"])), wanted etcdserver: requested lease not found
```

The `Empty reply from server` is caused by panic and server recover it
but it doesn't have chance to reply to client.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu 2023-01-12 16:32:39 +08:00
parent 46511ab96e
commit c320f75a15
3 changed files with 15 additions and 5 deletions

2
go.mod
View File

@ -18,7 +18,7 @@ require (
github.com/google/uuid v1.0.0
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/grpc-ecosystem/grpc-gateway v1.9.5
github.com/grpc-ecosystem/grpc-gateway v1.11.0
github.com/jonboulle/clockwork v0.1.0
github.com/json-iterator/go v1.1.11
github.com/modern-go/reflect2 v1.0.1

4
go.sum
View File

@ -82,8 +82,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI=
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.11.0 h1:aT5ISUniaOTErogCQ+4pGoYNBB6rm6Fq3g1v8QwYGas=
github.com/grpc-ecosystem/grpc-gateway v1.11.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=

View File

@ -343,7 +343,12 @@ func testV3CurlProclaimMissiongLeaderKey(cx ctlCtx) {
if err = cURLPost(cx.epc, cURLReq{
endpoint: path.Join(cx.apiPrefix, "/election/proclaim"),
value: string(pdata),
expected: `{"error":"\"leader\" field must be provided","message":"\"leader\" field must be provided","code":2}`,
// NOTE: The order of json fields is aligned with the runtime.errorBody
//
// REF:
// 1. https://github.com/grpc-ecosystem/grpc-gateway/blob/v1.11.0/runtime/errors.go#L73
// 2. https://github.com/grpc/grpc/blob/master/src/proto/grpc/status/status.proto#L82
expected: `{"error":"\"leader\" field must be provided","code":2,"message":"\"leader\" field must be provided"}`,
}); err != nil {
cx.t.Fatalf("failed post proclaim request (%s) (%v)", cx.apiPrefix, err)
}
@ -359,7 +364,12 @@ func testV3CurlResignMissiongLeaderKey(cx ctlCtx) {
if err := cURLPost(cx.epc, cURLReq{
endpoint: path.Join(cx.apiPrefix, "/election/resign"),
value: `{}`,
expected: `{"error":"\"leader\" field must be provided","message":"\"leader\" field must be provided","code":2}`,
// NOTE: The order of json fields is aligned with the runtime.errorBody
//
// REF:
// 1. https://github.com/grpc-ecosystem/grpc-gateway/blob/v1.11.0/runtime/errors.go#L73
// 2. https://github.com/grpc/grpc/blob/master/src/proto/grpc/status/status.proto#L82
expected: `{"error":"\"leader\" field must be provided","code":2,"message":"\"leader\" field must be provided"}`,
}); err != nil {
cx.t.Fatalf("failed post resign request (%s) (%v)", cx.apiPrefix, err)
}