Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix 'gogo/protobuf' compatibility issue #5969

Merged
merged 3 commits into from
Jul 18, 2016
Merged

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Jul 18, 2016

@gyuho gyuho changed the title Vendor fix *: fix 'gogo/protobuf' compatibility issue Jul 18, 2016
@gyuho
Copy link
Contributor Author

gyuho commented Jul 18, 2016

Partial fix for #5865

because...

Currently

curl -L http://localhost:2379/v3alpha/watch -X POST -d '{"create_request": {"key": "Zm9v"}}'

wouldn't work, with the server complaining this error in this code https://github.com/coreos/etcd/blob/master/etcdserver/etcdserverpb/rpc.pb.gw.go#L92-L93:

2016/07/18 09:24:36 Failed to decode request: EOF

Work-around to make watch work:

diff --git a/etcdserver/etcdserverpb/rpc.pb.gw.go b/etcdserver/etcdserverpb/rpc.pb.gw.go
index 4ee9685..1bdd637 100644
--- a/etcdserver/etcdserverpb/rpc.pb.gw.go
+++ b/etcdserver/etcdserverpb/rpc.pb.gw.go
@@ -10,8 +10,11 @@ It translates gRPC into RESTful JSON APIs.
 package etcdserverpb

 import (
+       "fmt"
        "io"
+       "io/ioutil"
        "net/http"
+       "strings"

        "github.com/golang/protobuf/proto"
        "github.com/grpc-ecosystem/grpc-gateway/runtime"
@@ -86,11 +89,14 @@ func request_Watch_Watch_0(ctx context.Context, marshaler runtime.Marshaler, cli
                grpclog.Printf("Failed to start streaming: %v", err)
                return nil, metadata, err
        }
-       dec := marshaler.NewDecoder(req.Body)
+       bts, _ := ioutil.ReadAll(req.Body)
+       fmt.Println(string(bts))
+
+       dec := marshaler.NewDecoder(strings.NewReader(string(bts)))
        handleSend := func() error {
                var protoReq WatchRequest
                err = dec.Decode(&protoReq)
-               if err != nil {
+               if err != nil && err != io.EOF {
                        grpclog.Printf("Failed to decode request: %v", err)
                        return err
                }

string(bts) here is {"create_request": {"key": "Zm9v"}}

and with additional error checking of err != io.EOF, everything works fine...

We need to find some ways to make dec.Decode handle io.EOF.

Will report upstream.

/cc @heyitsanthony @xiang90

@heyitsanthony
Copy link
Contributor

lgtm

@gyuho
Copy link
Contributor Author

gyuho commented Jul 18, 2016

merging after all greens. thanks.

@gyuho
Copy link
Contributor Author

gyuho commented Jul 18, 2016

Failure not related

--- FAIL: TestEmbedEtcd (1.13s)
    embed_test.go:78: 5: expected success, got error listen tcp 127.0.0.1:40026: bind: address already in use

Already reported in open issue https://github.com/coreos/etcd/issues/5953.

@gyuho gyuho merged commit dc80ae8 into etcd-io:master Jul 18, 2016
@gyuho gyuho deleted the vendor-fix branch July 18, 2016 17:56
@xiang90
Copy link
Contributor

xiang90 commented Jul 23, 2016

@gyuho Why do we sent a zero length request at the first place? The request you sent should not be a zero length one. I suspect that the jsonpb -> proto thing still not working correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Enums are not parsed correctly by v3alpha API when sent as JSON
3 participants