From 7f91a35313d26defc0241cd6d5a371ff91060a51 Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Tue, 27 Jan 2015 13:10:13 -0500 Subject: [PATCH] migrate: convert 0.4 terms to start at 1 --- migrate/etcd4.go | 2 ++ migrate/log.go | 2 +- migrate/snapshot.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/migrate/etcd4.go b/migrate/etcd4.go index 17abb16ae..2a2d57881 100644 --- a/migrate/etcd4.go +++ b/migrate/etcd4.go @@ -29,6 +29,8 @@ import ( "github.com/coreos/etcd/wal/walpb" ) +const termOffset4to2 = 1 + func snapDir4(dataDir string) string { return path.Join(dataDir, "snapshot") } diff --git a/migrate/log.go b/migrate/log.go index 6d8081380..78fe9d6c9 100644 --- a/migrate/log.go +++ b/migrate/log.go @@ -498,7 +498,7 @@ func toEntry2(ent4 *etcd4pb.LogEntry, raftMap map[string]uint64) (*raftpb.Entry, } ent2 := raftpb.Entry{ - Term: ent4.GetTerm(), + Term: ent4.GetTerm() + termOffset4to2, Index: ent4.GetIndex(), Type: cmd4.Type2(), Data: data, diff --git a/migrate/snapshot.go b/migrate/snapshot.go index bea959ff2..cc071d643 100644 --- a/migrate/snapshot.go +++ b/migrate/snapshot.go @@ -195,7 +195,7 @@ func (s *Snapshot4) Snapshot2() *raftpb.Snapshot { Data: newState, Metadata: raftpb.SnapshotMetadata{ Index: s.LastIndex, - Term: s.LastTerm, + Term: s.LastTerm + termOffset4to2, ConfState: raftpb.ConfState{ Nodes: nodeList, },