-
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
Added member interaction into EtcdProcessCluster #14404
Conversation
ac47a2e
to
6ce3d4a
Compare
Please resolve the conflict. |
6ce3d4a
to
3c46475
Compare
Signed-off-by: Vitalii Levitskii <[email protected]>
3c46475
to
76ab474
Compare
@ahrtr done, rebased on main |
@@ -516,6 +611,10 @@ func (epc *EtcdProcessCluster) Stop() (err error) { | |||
return err | |||
} | |||
|
|||
func (epc *EtcdProcessCluster) CtlClient() *EtcdctlV3 { |
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.
func (epc *EtcdProcessCluster) CtlClient() *EtcdctlV3 { | |
func (epc *EtcdProcessCluster) Client() *EtcdctlV3 { |
func (cfg *EtcdServerProcessConfig) SetInitialCluster(nodes []string, initialClusterState string) { | ||
cfg.InitialCluster = strings.Join(nodes, ",") | ||
cfg.Args = append(cfg.Args, "--initial-cluster", cfg.InitialCluster) | ||
cfg.Args = append(cfg.Args, "--initial-cluster-state", initialClusterState) | ||
} | ||
|
||
func (cfg *EtcdServerProcessConfig) EnableDiscovery(token string, endpoints []string) { | ||
cfg.Args = append(cfg.Args, fmt.Sprintf("--discovery-token=%s", token)) | ||
cfg.Args = append(cfg.Args, fmt.Sprintf("--discovery-endpoints=%s", strings.Join(endpoints, ","))) | ||
} |
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.
let's not implement setters for configuration structs. I think we should avoid mutating args when constructing EtcdServerProcess. One solution would be to separate args provided by caller (extraArgs
) from args generated from configuration fields (configArgs
).
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.
@biosvs After you resolve #14404 (comment), then this comment should can be resolved automatically.
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.
Overall I'm not big fan of complicating EtcdProcessCluster
code. From brief look at the code looks like you implement cluster resizes just for this test. I think dynamic cluster sizes over-complicate the code and are not worth it.
Instead of complicating library used by hundreds of tests, could we make just your test simpler?
For me problem is making list of members dynamic, which would be only used for this test. Could we maybe check if the test itself can be simpler? For testing My understanding is that we are just looking for a |
Hmm, can't agree here. |
I do not get time to have a deeper review on this PR, but my immediate feeling is it's a little over complicated. The gap mentioned in #14354 (comment) is that the current test framework has interface MemberAdd, but doesn't have interface method something like Please always keep OCP (Open Close principle) in mind: Open for extension, but close for modification. When updating existing framework, please try not to change the existing logic. Instead, please try to make your new code adapt to the existing framework. |
I'm afraid we're stuck with this PR (because we're in a kinda closed loop). Changed e2e test cannot be rewritten with common or integration framework, because we're testing interaction through different running instances (including updates via network). The same story is here: https://github.com/etcd-io/etcd/blob/main/tests/e2e/ctl_v3_snapshot_test.go#L258 Both these tests need actual member list changes. Both tests do it via raw commands. I tried to add these commands to e2e framework, but you think it's unnecessary. You're contributors, and if you're saying that it's easer to use raw commands for couple of tests - let it be. |
func (cfg *EtcdServerProcessConfig) EnableDiscovery(token string, endpoints []string) { | ||
cfg.Args = append(cfg.Args, fmt.Sprintf("--discovery-token=%s", token)) | ||
cfg.Args = append(cfg.Args, fmt.Sprintf("--discovery-endpoints=%s", strings.Join(endpoints, ","))) | ||
} |
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.
These two methods (SetInitialCluster
and EnableDiscovery
) are only used by SetInitialOrDiscovery
, it seems that we can just get the code included in it directly instead of creating two separate methods.
When I tried to enhance the existing e2e test framework, eventually it's similar to this PR. But the interface definition in my commit looks clearer, I also get rid of the |
Codecov Report
@@ Coverage Diff @@
## main #14404 +/- ##
==========================================
- Coverage 75.47% 74.75% -0.73%
==========================================
Files 457 457
Lines 37183 37207 +24
==========================================
- Hits 28065 27813 -252
- Misses 7361 7612 +251
- Partials 1757 1782 +25
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Maybe I didn't get the idea, but code looks broken for me:
|
The commit is just to demonstrate the high level idea instead of a PR ready for review. |
Then I didn't get the idea, sorry. You got rid of things that was introduced in order to make code workable. |
The initial value for |
Let's assume that initial configuration is:
Then node A has port 2000 + 15 = 2005, node B has port 2000 + 25 = 2010. Now imaging that I'm first removing node A and then adding new node C. What will I get? If I use cfg.ClusterSize or len(epc.Procs), I'll get port for new node = 2000 + 2*5 = 2010, which is overlapping with already running node B. |
Make sense to me, thanks for the clarification. |
@biosvs Could you resolve the inline comments? Please also rebase this PR. |
Continue to work on this PR in #14589 |
As I promised in #14354, trying to introduce to EtcdProcessCluster functions for changing cluster member list.
As an example rewrote e2e tests from mentioned pull request.