-
Notifications
You must be signed in to change notification settings - Fork 4
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
Make CETS joining logic more reliable #12
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #12 +/- ##
==========================================
+ Coverage 86.29% 90.69% +4.40%
==========================================
Files 8 8
Lines 372 430 +58
==========================================
+ Hits 321 390 +69
+ Misses 51 40 -11
☔ View full report in Codecov by Sentry. |
b4407ec
to
1b3f862
Compare
Add step function into cets_join
So servers could verify if join_ref matches
Add join_fails_before_send_dump_and_there_are_pending_remote_ops testcase
Add join_fails_in_check_fully_connected testcase
…stcase Add join_fails_because_pids_do_not_match_for_nodes_in_segment testcase
5a14046
to
aef32b8
Compare
Catching errors and converting errors to tuples is a bad idea Because it makes giant nested errors
1747ff3
to
17c1607
Compare
They break coverage report (underreported lines)
Add check_do_not_overlap into cets_join
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.
The code itself is OK for me 👍
I only have an issue with the actual concept of steps, which are checkpoints between steps. I think a cleaner option would be to use a fold
operation over a list of steps.
For example, see:
- https://github.com/esl/MongooseIM/blob/master/src/system_metrics/mongoose_system_metrics_collector.erl#L46
- https://github.com/esl/MongooseIM/blob/master/src/config/mongoose_config_parser_toml.erl#L142
- https://github.com/esl/MongooseIM/blob/master/src/graphql/mongoose_graphql_commands.erl#L70
I also consider the new syntax for logging errors a bit of verbose, and now we contruct the terms even if logs are disabled for the given level, which kind of defeats the purpose of the macro...
src/cets_join.erl
Outdated
JoinRef. | ||
|
||
-spec run_step(step(), join_opts()) -> ok. | ||
run_step(Step, #{step_handler := F}) -> |
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.
For me this is counter-intuitive, because this function isn't actually running the step, but runs some custom injected logic between steps. It's a lot of bending the code to fit the tests, and gives the impression of being overly complicated...
src/cets_join.erl
Outdated
Result -> | ||
Result | ||
end. | ||
|
||
join2(_Info, LocalPid, RemotePid) -> | ||
join2(_Info, LocalPid, RemotePid, JoinOpts) -> | ||
run_step(join_start, JoinOpts), |
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.
For me it would be cleaner if there was a lists:foldl
over a list of functions performing the actual steps, and in tests you could use meck
to inject some logic when needed - by changing the actual step function.
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.
Looks cleaner with the checkpoints
This issue addresses MIM-1968.
The changes include:
{error, {error, _}_}
when there is long call inside of a long operationLOG_ERROR
call and pass it into it. I don't think there would be any performance issues (unless someone disables all log messages), but still we could fix it once OTP fixes cover tool. For now I prefer good cover reports - they actually allow to find errors in logic Coverage is broken for multiline logging call erlang/otp#7531