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

feat: auto detecting local IP to use as hostname #5314

Merged
merged 7 commits into from
Jan 8, 2025
Merged

Conversation

WenyXu
Copy link
Member

@WenyXu WenyXu commented Jan 8, 2025

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

Automatically detect the local IP to enable deployment in container environments where pod IPs cannot be obtained.

After enabling this feature, the datanode will report the auto-detected IPs as peer addresses.

mysql> select * from cluster_info;
+---------+-----------+------------------+---------+------------+----------------------------+------------------+-------------+
| peer_id | peer_type | peer_addr        | version | git_commit | start_time                 | uptime           | active_time |
+---------+-----------+------------------+---------+------------+----------------------------+------------------+-------------+
|      -1 | METASRV   | 10.244.0.44:3002 | 0.12.0  | c305b2b4   | 2025-01-08 07:07:42.208000 | 2h 39m 55s 573ms | NULL        |
|       0 | DATANODE  | 10.244.0.47:4001 | 0.12.0  | c305b2b4   | 2025-01-08 07:07:52.415000 | 2h 39m 45s 366ms | 2s 227ms    |
|       1 | DATANODE  | 10.244.0.48:4001 | 0.12.0  | c305b2b4   | 2025-01-08 07:07:52.415000 | 2h 39m 45s 366ms | 2s 741ms    |
|      -1 | FRONTEND  | 127.0.0.1:4001   | 0.12.0  | c305b2b4   | 2025-01-08 07:07:57.806000 | 2h 39m 39s 975ms | 3s 380ms    |
+---------+-----------+------------------+---------+------------+----------------------------+------------------+-------------+
6 rows in set (0.01 sec)

PR Checklist

Please convert it to a draft if some of the following conditions are not met.

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.
  • API changes are backward compatible.
  • Schema or data changes are backward compatible.

@WenyXu WenyXu requested review from MichaelScofield and a team as code owners January 8, 2025 07:15
Copy link
Contributor

coderabbitai bot commented Jan 8, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jan 8, 2025
@WenyXu WenyXu changed the title feat: auto detecting hostname feat: auto detecting local IP to use as hostname Jan 8, 2025
@sunng87
Copy link
Member

sunng87 commented Jan 8, 2025

We don't need to create a new configuration item for this. Just make hostname an optional field and use local-ip-address when it's not provided.

But what if there are multiple network interfaces?

@sunng87 sunng87 requested a review from zyy17 January 8, 2025 07:28
@v0y4g3r
Copy link
Contributor

v0y4g3r commented Jan 8, 2025

We don't need to create a new configuration item for this. Just make hostname an optional field and use local-ip-address when it's not provided.

But what if there are multiple network interfaces?

That crate uses netlink to find out local ip address, so system route table determines which interface to use when multiple interface are present.

@WenyXu WenyXu requested review from fengjiachun and v0y4g3r January 8, 2025 08:19
@github-actions github-actions bot added docs-required This change requires docs update. and removed docs-not-required This change does not impact docs. labels Jan 8, 2025
@WenyXu WenyXu force-pushed the feat/detect_hostname branch from 3d31b31 to c9ffa91 Compare January 8, 2025 08:28
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 51.80723% with 40 lines in your changes missing coverage. Please review.

Project coverage is 84.11%. Comparing base (c305b2b) to head (3fa5248).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5314      +/-   ##
==========================================
- Coverage   84.14%   84.11%   -0.04%     
==========================================
  Files        1200     1202       +2     
  Lines      225414   226112     +698     
==========================================
+ Hits       189682   190187     +505     
- Misses      35732    35925     +193     

@github-actions github-actions bot added docs-not-required This change does not impact docs. and removed docs-required This change requires docs update. labels Jan 8, 2025
Copy link
Contributor

@v0y4g3r v0y4g3r left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@fengjiachun fengjiachun left a comment

Choose a reason for hiding this comment

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

LGTM

@v0y4g3r v0y4g3r enabled auto-merge January 8, 2025 09:59
@WenyXu WenyXu force-pushed the feat/detect_hostname branch from b3e38bb to 3fa5248 Compare January 8, 2025 11:42
@v0y4g3r v0y4g3r added this pull request to the merge queue Jan 8, 2025
Merged via the queue into main with commit 7f307a4 Jan 8, 2025
46 checks passed
@v0y4g3r v0y4g3r deleted the feat/detect_hostname branch January 8, 2025 12:47
v0y4g3r pushed a commit to v0y4g3r/greptimedb that referenced this pull request Jan 19, 2025
* feat: auto detecting hostname

* chore: update config.md

* chore: bring back hostname

* chore: apply suggestions from CR

* chore: use const

* chore: apply suggesions from CR

* fix: fix sqlness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants