-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop writing v2store and validate confChange against v3store instead of v2store #17019
Draft
ahrtr
wants to merge
4
commits into
etcd-io:main
Choose a base branch
from
ahrtr:remove_v2store_write_20231125
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,12 @@ package membership | |
import ( | ||
"encoding/json" | ||
"fmt" | ||
"path" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.uber.org/zap/zaptest" | ||
|
||
"go.etcd.io/etcd/client/pkg/v3/testutil" | ||
"go.etcd.io/etcd/client/pkg/v3/types" | ||
"go.etcd.io/etcd/server/v3/etcdserver/api/v2store" | ||
"go.etcd.io/etcd/server/v3/mock/mockstore" | ||
|
@@ -278,6 +276,8 @@ func TestClusterValidateAndAssignIDs(t *testing.T) { | |
|
||
func TestClusterValidateConfigurationChange(t *testing.T) { | ||
cl := NewCluster(zaptest.NewLogger(t), WithMaxLearners(1)) | ||
be := newMembershipBackend() | ||
cl.SetBackend(be) | ||
cl.SetStore(v2store.New()) | ||
for i := 1; i <= 4; i++ { | ||
var isLearner bool | ||
|
@@ -455,7 +455,7 @@ func TestClusterValidateConfigurationChange(t *testing.T) { | |
}, | ||
} | ||
for i, tt := range tests { | ||
err := cl.ValidateConfigurationChange(tt.cc) | ||
err := cl.ValidateConfigurationChange(tt.cc, true) | ||
if err != tt.werr { | ||
t.Errorf("#%d: validateConfigurationChange error = %v, want %v", i, err, tt.werr) | ||
} | ||
|
@@ -517,52 +517,6 @@ func TestNodeToMemberBad(t *testing.T) { | |
} | ||
} | ||
|
||
func TestClusterAddMember(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please migrate such tests v3 instead of just removing them |
||
st := mockstore.NewRecorder() | ||
c := newTestCluster(t, nil) | ||
c.SetStore(st) | ||
c.AddMember(newTestMember(1, nil, "node1", nil), true) | ||
|
||
wactions := []testutil.Action{ | ||
{ | ||
Name: "Create", | ||
Params: []any{ | ||
path.Join(StoreMembersPrefix, "1", "raftAttributes"), | ||
false, | ||
`{"peerURLs":null}`, | ||
false, | ||
v2store.TTLOptionSet{ExpireTime: v2store.Permanent}, | ||
}, | ||
}, | ||
} | ||
if g := st.Action(); !reflect.DeepEqual(g, wactions) { | ||
t.Errorf("actions = %v, want %v", g, wactions) | ||
} | ||
} | ||
|
||
func TestClusterAddMemberAsLearner(t *testing.T) { | ||
st := mockstore.NewRecorder() | ||
c := newTestCluster(t, nil) | ||
c.SetStore(st) | ||
c.AddMember(newTestMemberAsLearner(1, []string{}, "node1", []string{"http://node1"}), true) | ||
|
||
wactions := []testutil.Action{ | ||
{ | ||
Name: "Create", | ||
Params: []any{ | ||
path.Join(StoreMembersPrefix, "1", "raftAttributes"), | ||
false, | ||
`{"peerURLs":[],"isLearner":true}`, | ||
false, | ||
v2store.TTLOptionSet{ExpireTime: v2store.Permanent}, | ||
}, | ||
}, | ||
} | ||
if g := st.Action(); !reflect.DeepEqual(g, wactions) { | ||
t.Errorf("actions = %v, want %v", g, wactions) | ||
} | ||
} | ||
|
||
func TestClusterMembers(t *testing.T) { | ||
cls := newTestCluster(t, []*Member{ | ||
{ID: 1}, | ||
|
@@ -583,21 +537,6 @@ func TestClusterMembers(t *testing.T) { | |
} | ||
} | ||
|
||
func TestClusterRemoveMember(t *testing.T) { | ||
st := mockstore.NewRecorder() | ||
c := newTestCluster(t, nil) | ||
c.SetStore(st) | ||
c.RemoveMember(1, true) | ||
|
||
wactions := []testutil.Action{ | ||
{Name: "Delete", Params: []any{MemberStoreKey(1), true, true}}, | ||
{Name: "Create", Params: []any{RemovedMemberStoreKey(1), false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}}}, | ||
} | ||
if !reflect.DeepEqual(st.Action(), wactions) { | ||
t.Errorf("actions = %v, want %v", st.Action(), wactions) | ||
} | ||
} | ||
|
||
func TestClusterUpdateAttributes(t *testing.T) { | ||
name := "etcd" | ||
clientURLs := []string{"http://127.0.0.1:4001"} | ||
|
@@ -903,7 +842,7 @@ func TestIsReadyToPromoteMember(t *testing.T) { | |
// 1/1 members ready, should succeed (quorum = 1, new quorum = 2) | ||
[]*Member{ | ||
newTestMember(1, nil, "1", nil), | ||
newTestMemberAsLearner(2, nil, "2", nil), | ||
newTestMemberAsLearner(2, []string{}, "2", []string{}), | ||
}, | ||
2, | ||
true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not true, we are still applying confChange as long as we bootstrap from snapshot and not consistent index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, this is a longstanding design problem to me.
Current status summary
main
branch for now), we load all data from v3store on startup, but we still replay WAL entries on top of v2 snapshot.skiping already applied entries
" doesn't work anymore.Solutions
Short-term solutions
Long-term solutions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, #17017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have draft implementation for that. #17022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v3 db snapshot is not a thing. That's an incompatible concept. Recommend reading the raft paper on in-memory snapshotable storage (etcd v2) vs persistent one (etcd v3).