etcdserver: go back to marshal request in 2.1 way

It fixes the problem that 2.1 cannot roll upgrade to 2.2 smoothly
because 2.1 cannot understand the bytes marshalled at 2.2.
This commit is contained in:
Yicheng Qin
2015-08-13 13:41:52 -07:00
parent a46943548a
commit 0fdb77aea2
2 changed files with 5 additions and 9 deletions

View File

@@ -529,9 +529,7 @@ func (s *EtcdServer) Do(ctx context.Context, r pb.Request) (Response, error) {
}
switch r.Method {
case "POST", "PUT", "DELETE", "QGET":
var raftReq pb.InternalRaftRequest
raftReq.V2 = &r
data, err := raftReq.Marshal()
data, err := r.Marshal()
if err != nil {
return Response{}, err
}

View File

@@ -989,11 +989,10 @@ func TestPublish(t *testing.T) {
t.Fatalf("action = %s, want Propose", action[0].Name)
}
data := action[0].Params[0].([]byte)
var rr pb.InternalRaftRequest
if err := rr.Unmarshal(data); err != nil {
var r pb.Request
if err := r.Unmarshal(data); err != nil {
t.Fatalf("unmarshal request error: %v", err)
}
r := rr.V2
if r.Method != "PUT" {
t.Errorf("method = %s, want PUT", r.Method)
}
@@ -1073,11 +1072,10 @@ func TestUpdateVersion(t *testing.T) {
t.Fatalf("action = %s, want Propose", action[0].Name)
}
data := action[0].Params[0].([]byte)
var rr pb.InternalRaftRequest
if err := rr.Unmarshal(data); err != nil {
var r pb.Request
if err := r.Unmarshal(data); err != nil {
t.Fatalf("unmarshal request error: %v", err)
}
r := rr.V2
if r.Method != "PUT" {
t.Errorf("method = %s, want PUT", r.Method)
}