Skip to content
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

Convert 0.0.0.0 to local ip addresses when matching the cluster node #1392

Merged
merged 7 commits into from
Apr 20, 2023

Conversation

zevin02
Copy link
Contributor

@zevin02 zevin02 commented Apr 17, 2023

fixes: #1381

  • Add a function to get all local IP addresses

src/cluster/cluster.cc Outdated Show resolved Hide resolved
src/cluster/cluster.cc Outdated Show resolved Hide resolved
@torwig
Copy link
Contributor

torwig commented Apr 17, 2023

@zevin02 It's very handy to run ./x.py format before committing the changes - it will format the C++ source code automatically so the CI's linter will be happy.

@PragmaTwice
Copy link
Member

PragmaTwice commented Apr 17, 2023

Hi @zevin02, thanks for your contribution!

We setup lots of code checks in our CI, which requires you to pass for better code quality.

For example, from a glance to your code, maybe these checks will fail:

  • local variables must be lower_case with underscore,
  • NULL must be replaced with nullptr

You can check the CI log for more details and for how to modify your code to pass the CI.

It is recommended to try some commands to solve these problems, but maybe not all problems:

  • ./x.py format
  • ./x.py check tidy --fix

Another thing is that, it would be better to have some unit tests for this function before it is merged : )

@git-hulk git-hulk requested a review from PragmaTwice April 18, 2023 02:02
fixes: apache#1381

- Add a function to get all local IP addresses

Signed-off-by: Zewen Xu <zevin9427@gmail.com>
src/cluster/cluster.cc Outdated Show resolved Hide resolved
src/cluster/cluster.cc Outdated Show resolved Hide resolved
src/cluster/cluster.cc Outdated Show resolved Hide resolved
src/cluster/cluster.cc Outdated Show resolved Hide resolved
src/cluster/cluster.cc Outdated Show resolved Hide resolved
src/cluster/cluster.cc Outdated Show resolved Hide resolved
- Move the `GetLocalIpAddresses` function to `common/io_util.cc`
- Add `common/io_util.h` header to `cluster/cluster.h`
- Use `util::GetLocalIpAddresses()` instead of the previously defined function in `cluster.cc`

Signed-off-by: Zewen Xu <zevin9427@gmail.com>
@zevin02
Copy link
Contributor Author

zevin02 commented Apr 19, 2023

@PragmaTwice I think I solved all the problems, can you give me a review

@PragmaTwice
Copy link
Member

PragmaTwice commented Apr 19, 2023

@PragmaTwice I think I solved all the problems, can you give me a review

Sure! But as I mentioned in #1392 (comment), you need first to make the CI pass, which currently failed.

./x.py format

zevin02 and others added 2 commits April 19, 2023 18:46
Signed-off-by: Zewen Xu <zevin9427@gmail.com>
src/cluster/cluster.cc Outdated Show resolved Hide resolved
src/common/io_util.h Outdated Show resolved Hide resolved
src/cluster/cluster.cc Outdated Show resolved Hide resolved
src/cluster/cluster.cc Outdated Show resolved Hide resolved
Copy link
Member

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest looks good to me. cc @git-hulk

@git-hulk
Copy link
Member

The rest looks good to me. cc @git-hulk

@PragmaTwice I do a minor refactor, can help to take a look again.

@git-hulk git-hulk requested review from torwig and PragmaTwice April 19, 2023 15:11
@git-hulk git-hulk requested a review from enjoy-binbin April 19, 2023 15:11
@git-hulk git-hulk changed the title feat: implement local IP address retrieval function Convert 0.0.0.0 to local ip addresses when matching the cluster node Apr 19, 2023
Copy link
Contributor

@torwig torwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, LGTM, but I have a few comments.

src/common/io_util.cc Outdated Show resolved Hide resolved
src/common/io_util.cc Outdated Show resolved Hide resolved
src/common/io_util.cc Outdated Show resolved Hide resolved
- Check for IPv6 addresses in `MatchListeningIP`
- Remove unnecessary comment about loopback addresses in `GetLocalIPAddresses`

Signed-off-by: Zewen Xu <zevin9427@gmail.com>
Copy link
Contributor

@torwig torwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PragmaTwice
Copy link
Member

Thanks for your contribution! Merging...

@PragmaTwice PragmaTwice merged commit 13b8287 into apache:unstable Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SetClusterNodes allow to match localhost and real ip when listening on 0.0.0.0
5 participants