mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Switch to validating v3 when v2 and v3 are synchronized
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
parent
6db5e00103
commit
4fe46f9203
@ -303,9 +303,16 @@ 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) error {
|
||||
// TODO: this must be switched to backend as well.
|
||||
membersMap, removedMap := membersFromStore(c.lg, c.v2store)
|
||||
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)
|
||||
}
|
||||
|
||||
id := types.ID(cc.NodeID)
|
||||
if removedMap[id] {
|
||||
return ErrIDRemoved
|
||||
|
@ -455,7 +455,7 @@ func TestClusterValidateConfigurationChange(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
err := cl.ValidateConfigurationChange(tt.cc)
|
||||
err := cl.ValidateConfigurationChange(tt.cc, false)
|
||||
if err != tt.werr {
|
||||
t.Errorf("#%d: validateConfigurationChange error = %v, want %v", i, err, tt.werr)
|
||||
}
|
||||
|
@ -1935,7 +1935,7 @@ func removeNeedlessRangeReqs(txn *pb.TxnRequest) {
|
||||
// applyConfChange applies a ConfChange to the server. It is only
|
||||
// invoked with a ConfChange that has already passed through Raft
|
||||
func (s *EtcdServer) applyConfChange(cc raftpb.ConfChange, confState *raftpb.ConfState, shouldApplyV3 membership.ShouldApplyV3) (bool, error) {
|
||||
if err := s.cluster.ValidateConfigurationChange(cc); err != nil {
|
||||
if err := s.cluster.ValidateConfigurationChange(cc, shouldApplyV3); err != nil {
|
||||
cc.NodeID = raft.None
|
||||
s.r.ApplyConfChange(cc)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user