Skip to content

Commit

Permalink
upgrade etcd to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
mangalaman93 committed Aug 18, 2023
1 parent 4fc9cfd commit 8f9919f
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 67 deletions.
4 changes: 2 additions & 2 deletions conn/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (

"github.com/golang/glog"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"
otrace "go.opencensus.io/trace"

"github.com/dgraph-io/badger/v4/y"
Expand Down
4 changes: 2 additions & 2 deletions conn/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"time"

"github.com/stretchr/testify/require"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"

"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/raftwal"
Expand Down
4 changes: 2 additions & 2 deletions conn/raft_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

"github.com/golang/glog"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3/raftpb"
otrace "go.opencensus.io/trace"

"github.com/dgraph-io/dgo/v230/protos/api"
Expand Down Expand Up @@ -163,7 +163,7 @@ func (w *RaftServer) IsPeer(ctx context.Context, rc *pb.RaftContext) (
return &pb.PeerResponse{}, nil
}

for _, raftIdx := range confState.Nodes {
for _, raftIdx := range confState.Voters {
if rc.Id == raftIdx {
return &pb.PeerResponse{Status: true}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions dgraph/cmd/debug/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"strings"

humanize "github.com/dustin/go-humanize"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"

"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/raftwal"
Expand Down
8 changes: 4 additions & 4 deletions dgraph/cmd/zero/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (
"github.com/golang/glog"
"github.com/google/uuid"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"
ostats "go.opencensus.io/stats"
"go.opencensus.io/tag"
otrace "go.opencensus.io/trace"
Expand Down Expand Up @@ -656,7 +656,7 @@ func (n *node) initAndStartNode() error {
var zs pb.ZeroSnapshot
x.Check(zs.Unmarshal(sp.Data))
n.server.SetMembershipState(zs.State)
for _, id := range sp.Metadata.ConfState.Nodes {
for _, id := range sp.Metadata.ConfState.Voters {
n.Connect(id, zs.State.Zeros[id].Addr)
}
}
Expand Down Expand Up @@ -700,7 +700,7 @@ func (n *node) initAndStartNode() error {
cancel()
}
glog.Infof("[%#x] Starting node\n", n.Id)
n.SetRaft(raft.StartNode(n.Cfg, nil))
n.SetRaft(raft.RestartNode(n.Cfg))

default:
glog.Infof("Starting a brand new node")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ require (
github.com/stretchr/testify v1.8.4
github.com/twpayne/go-geom v1.0.5
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c
go.etcd.io/etcd v0.5.0-alpha.5.0.20190108173120-83c051b701d3
go.etcd.io/etcd/raft/v3 v3.5.9
go.opencensus.io v0.22.5
go.uber.org/zap v1.16.0
golang.org/x/crypto v0.9.0
Expand Down
40 changes: 4 additions & 36 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion raftwal/encryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3/raftpb"
)

func TestEntryReadWrite(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion raftwal/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

"github.com/golang/glog"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3/raftpb"

"github.com/dgraph-io/badger/v4"
"github.com/dgraph-io/badger/v4/pb"
Expand Down
4 changes: 2 additions & 2 deletions raftwal/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

"github.com/golang/glog"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"

"github.com/dgraph-io/dgraph/x"
"github.com/dgraph-io/ristretto/z"
Expand Down
4 changes: 2 additions & 2 deletions raftwal/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/golang/glog"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"
"golang.org/x/net/trace"

"github.com/dgraph-io/dgraph/x"
Expand Down
6 changes: 3 additions & 3 deletions raftwal/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"

"github.com/dgraph-io/dgraph/x"
)
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestStorageCreateSnapshot(t *testing.T) {
ds := Init(dir)

ents := []raftpb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
cs := &raftpb.ConfState{Nodes: []uint64{1, 2, 3}}
cs := &raftpb.ConfState{Voters: []uint64{1, 2, 3}}
data := []byte("data")

tests := []struct {
Expand Down
4 changes: 2 additions & 2 deletions raftwal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/golang/glog"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"

"github.com/dgraph-io/badger/v4/y"
"github.com/dgraph-io/dgraph/x"
Expand Down
2 changes: 1 addition & 1 deletion worker/cdc_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/golang/glog"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3/raftpb"

"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/protos/pb"
Expand Down
8 changes: 4 additions & 4 deletions worker/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (
"github.com/dustin/go-humanize"
"github.com/golang/glog"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3"
"go.etcd.io/etcd/raft/v3/raftpb"
ostats "go.opencensus.io/stats"
"go.opencensus.io/tag"
otrace "go.opencensus.io/trace"
Expand Down Expand Up @@ -1813,7 +1813,7 @@ func (n *node) InitAndStartNode() {

// TODO: Making connections here seems unnecessary, evaluate.
members := groups().members(n.gid)
for _, id := range sp.Metadata.ConfState.Nodes {
for _, id := range sp.Metadata.ConfState.Voters {
m, ok := members[id]
if ok {
n.Connect(id, m.Addr)
Expand All @@ -1839,7 +1839,7 @@ func (n *node) InitAndStartNode() {
// snapshot as needed after joining the group, instead of us forcing one upfront.
glog.Infoln("Trying to join peers.")
n.retryUntilSuccess(n.joinPeers, time.Second)
n.SetRaft(raft.StartNode(n.Cfg, nil))
n.SetRaft(raft.RestartNode(n.Cfg))
} else {
peers := []raft.Peer{{ID: n.Id}}
n.SetRaft(raft.StartNode(n.Cfg, peers))
Expand Down
2 changes: 1 addition & 1 deletion worker/draft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.etcd.io/etcd/raft/raftpb"
"go.etcd.io/etcd/raft/v3/raftpb"

"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/protos/pb"
Expand Down
2 changes: 1 addition & 1 deletion worker/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/dustin/go-humanize"
"github.com/golang/glog"
"github.com/pkg/errors"
"go.etcd.io/etcd/raft"
"go.etcd.io/etcd/raft/v3"

"github.com/dgraph-io/badger/v4"
"github.com/dgraph-io/dgraph/conn"
Expand Down

0 comments on commit 8f9919f

Please sign in to comment.