mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Revert "Switch to validating v3 when v2 and v3 are synchronized"
This reverts commit 4fe46f9203.
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
@@ -303,16 +303,9 @@ func (c *RaftCluster) Recover(onSet func(*zap.Logger, *semver.Version)) {
|
||||
|
||||
// ValidateConfigurationChange takes a proposed ConfChange and
|
||||
// ensures that it is still valid.
|
||||
func (c *RaftCluster) ValidateConfigurationChange(cc raftpb.ConfChange, shouldApplyV3 ShouldApplyV3) error {
|
||||
var membersMap map[types.ID]*Member
|
||||
var removedMap map[types.ID]bool
|
||||
|
||||
if shouldApplyV3 {
|
||||
membersMap, removedMap = c.be.MustReadMembersFromBackend()
|
||||
} else {
|
||||
membersMap, removedMap = membersFromStore(c.lg, c.v2store)
|
||||
}
|
||||
|
||||
func (c *RaftCluster) ValidateConfigurationChange(cc raftpb.ConfChange) error {
|
||||
// TODO: this must be switched to backend as well.
|
||||
membersMap, removedMap := membersFromStore(c.lg, c.v2store)
|
||||
id := types.ID(cc.NodeID)
|
||||
if removedMap[id] {
|
||||
return ErrIDRemoved
|
||||
|
||||
@@ -276,14 +276,7 @@ func TestClusterValidateAndAssignIDs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestClusterValidateConfigurationChangeV3(t *testing.T) {
|
||||
testClusterValidateConfigurationChange(t, true)
|
||||
}
|
||||
func TestClusterValidateConfigurationChangeV2(t *testing.T) {
|
||||
testClusterValidateConfigurationChange(t, false)
|
||||
}
|
||||
|
||||
func testClusterValidateConfigurationChange(t *testing.T, shouldApplyV3 ShouldApplyV3) {
|
||||
cl := NewCluster(zaptest.NewLogger(t), WithMaxLearners(1))
|
||||
be := newMembershipBackend()
|
||||
cl.SetBackend(be)
|
||||
@@ -464,7 +457,7 @@ func testClusterValidateConfigurationChange(t *testing.T, shouldApplyV3 ShouldAp
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
err := cl.ValidateConfigurationChange(tt.cc, shouldApplyV3)
|
||||
err := cl.ValidateConfigurationChange(tt.cc)
|
||||
if err != tt.werr {
|
||||
t.Errorf("#%d: validateConfigurationChange error = %v, want %v", i, err, tt.werr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user