-
Notifications
You must be signed in to change notification settings - Fork 730
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
Move port and cport range check just before clusterStartHandshake function #1686
base: unstable
Are you sure you want to change the base?
Conversation
470e164
to
007f9c6
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1686 +/- ##
=========================================
Coverage 71.17% 71.17%
=========================================
Files 123 123
Lines 65641 65644 +3
=========================================
+ Hits 46720 46724 +4
+ Misses 18921 18920 -1
|
src/cluster.h
Outdated
@@ -134,4 +134,5 @@ int isNodeAvailable(clusterNode *node); | |||
long long getNodeReplicationOffset(clusterNode *node); | |||
sds aggregateClientOutputBuffer(client *c); | |||
void resetClusterStats(void); | |||
int verifyPortNumber(client *c, long long *port, long long *cport); |
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.
This function does more than just verification, it also parses and assigns port values. Consider renaming it to something like parseAndValidatePorts
for better clarity.
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.
It makes sense to me. Will update.
56b0034
to
1ab8b98
Compare
The behavior change is that CLUSTER MEET can return an error instead of OK when the ports are invalid. This means the user can see the error early and understand what's wrong. This is the user-visible change, so it should be the title of the PR I think. The rest is just refactoring which is not important for users and release notes. |
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.
why we need this? The old code also seems to be very easy to understand and maintain
Current old cause developers hard to identify the problem. Existing logic is to check port,, and then in function clusterStartHandshake check the ip first and check the port again. The easier way to put all port checking logic together, and then check the ip. |
@enjoy-binbin @hwware The first commit is smaller. It just moves the check from clusterStartHandshake to CLUSTER MEET so it can return an error, without extra refactoring. |
1ab8b98
to
656abde
Compare
Yes, I just make thing easier. It looks like i update codes to the fist commit, and check the port and cport in the Cluster Meet part. |
Signed-off-by: hwware <[email protected]>
Signed-off-by: hwware <[email protected]>
Signed-off-by: hwware <[email protected]>
Signed-off-by: hwware <[email protected]>
ea8755d
to
b5e4e19
Compare
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.
Yes, this is simpler. I like it more. @enjoy-binbin WDYT?
I have just a minor comment about the error message.
Co-authored-by: Viktor Söderqvist <[email protected]> Signed-off-by: Wen Hui <[email protected]>
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.
LGTM.
Before merge, please update the PR title to clarify the user-visible behavior, that CLUSTER MEET validates the ports and returns error for invalid ports.
That is what we should mention in the release notes.
Now for the cluster meet command, we first check the port and cport number, and then the function clusterStartHandshake() is called.
In the function clusterStartHandshake(), ip address is checked first and then port and cport range are checked.
Even port or cport range is out of bound, only error message "Invalid node address specified" is reported.
This is not correct.
In this PR, I just make the port and cport check together before clusterStartHandshake() function. Thus the port number and range can be checked together.