mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
clientv3,etcdctl: support structured logger
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
d1c7d40a5e
commit
6dbce6b9a4
@ -24,6 +24,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
|
||||
"github.com/coreos/etcd/integration"
|
||||
"github.com/coreos/etcd/lease"
|
||||
@ -145,7 +147,7 @@ func TestMaintenanceSnapshotErrorInflight(t *testing.T) {
|
||||
clus.Members[0].Stop(t)
|
||||
dpath := filepath.Join(clus.Members[0].DataDir, "member", "snap", "db")
|
||||
b := backend.NewDefaultBackend(dpath)
|
||||
s := mvcc.NewStore(b, &lease.FakeLessor{}, nil)
|
||||
s := mvcc.NewStore(zap.NewExample(), b, &lease.FakeLessor{}, nil)
|
||||
rev := 100000
|
||||
for i := 2; i <= rev; i++ {
|
||||
s.Put([]byte(fmt.Sprintf("%10d", i)), bytes.Repeat([]byte("a"), 1024), lease.NoLease)
|
||||
|
@ -35,6 +35,7 @@ import (
|
||||
|
||||
bolt "github.com/coreos/bbolt"
|
||||
"github.com/urfave/cli"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func NewBackupCommand() cli.Command {
|
||||
@ -86,7 +87,7 @@ func handleBackup(c *cli.Context) error {
|
||||
metadata.NodeID = idgen.Next()
|
||||
metadata.ClusterID = idgen.Next()
|
||||
|
||||
neww, err := wal.Create(destWAL, pbutil.MustMarshal(&metadata))
|
||||
neww, err := wal.Create(zap.NewExample(), destWAL, pbutil.MustMarshal(&metadata))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -102,14 +103,14 @@ func handleBackup(c *cli.Context) error {
|
||||
}
|
||||
|
||||
func saveSnap(destSnap, srcSnap string) (walsnap walpb.Snapshot) {
|
||||
ss := raftsnap.New(srcSnap)
|
||||
ss := raftsnap.New(zap.NewExample(), srcSnap)
|
||||
snapshot, err := ss.Load()
|
||||
if err != nil && err != raftsnap.ErrNoSnapshot {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if snapshot != nil {
|
||||
walsnap.Index, walsnap.Term = snapshot.Metadata.Index, snapshot.Metadata.Term
|
||||
newss := raftsnap.New(destSnap)
|
||||
newss := raftsnap.New(zap.NewExample(), destSnap)
|
||||
if err = newss.SaveSnap(*snapshot); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -118,7 +119,7 @@ func saveSnap(destSnap, srcSnap string) (walsnap walpb.Snapshot) {
|
||||
}
|
||||
|
||||
func loadWAL(srcWAL string, walsnap walpb.Snapshot, v3 bool) (etcdserverpb.Metadata, raftpb.HardState, []raftpb.Entry) {
|
||||
w, err := wal.OpenForRead(srcWAL, walsnap)
|
||||
w, err := wal.OpenForRead(zap.NewExample(), srcWAL, walsnap)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import (
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -127,7 +128,7 @@ func prepareBackend() backend.Backend {
|
||||
|
||||
func rebuildStoreV2() (v2store.Store, uint64) {
|
||||
var index uint64
|
||||
cl := membership.NewCluster("")
|
||||
cl := membership.NewCluster(zap.NewExample(), "")
|
||||
|
||||
waldir := migrateWALdir
|
||||
if len(waldir) == 0 {
|
||||
@ -135,7 +136,7 @@ func rebuildStoreV2() (v2store.Store, uint64) {
|
||||
}
|
||||
snapdir := filepath.Join(migrateDatadir, "member", "snap")
|
||||
|
||||
ss := raftsnap.New(snapdir)
|
||||
ss := raftsnap.New(zap.NewExample(), snapdir)
|
||||
snapshot, err := ss.Load()
|
||||
if err != nil && err != raftsnap.ErrNoSnapshot {
|
||||
ExitWithError(ExitError, err)
|
||||
@ -147,7 +148,7 @@ func rebuildStoreV2() (v2store.Store, uint64) {
|
||||
index = snapshot.Metadata.Index
|
||||
}
|
||||
|
||||
w, err := wal.OpenForRead(waldir, walsnap)
|
||||
w, err := wal.OpenForRead(zap.NewExample(), waldir, walsnap)
|
||||
if err != nil {
|
||||
ExitWithError(ExitError, err)
|
||||
}
|
||||
@ -169,7 +170,7 @@ func rebuildStoreV2() (v2store.Store, uint64) {
|
||||
cl.SetStore(st)
|
||||
cl.Recover(api.UpdateCapability)
|
||||
|
||||
applier := etcdserver.NewApplierV2(st, cl)
|
||||
applier := etcdserver.NewApplierV2(zap.NewExample(), st, cl)
|
||||
for _, ent := range ents {
|
||||
if ent.Type == raftpb.EntryConfChange {
|
||||
var cc raftpb.ConfChange
|
||||
|
Loading…
x
Reference in New Issue
Block a user