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

fix: wrong frontend registration address #4199

Merged
merged 6 commits into from
Jun 26, 2024

Conversation

killme2008
Copy link
Contributor

@killme2008 killme2008 commented Jun 24, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

#4186

What's changed and what's your intention?

Fixed the wrong peer address that frontend registers.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

  • New Features

    • Added a new configuration parameter grpc.hostname to improve clarity and understanding of its usage for external connections.
  • Improvements

    • Updated configuration files to provide clarification on the hostname field for gRPC servers, enhancing documentation for end-users.
  • Refactor

    • Renamed server_addr to peer_addr in heartbeat components for consistency.
    • Improved address resolution logic for better handling of hostname and port.

Copy link
Contributor

coderabbitai bot commented Jun 24, 2024

Warning

Rate limit exceeded

@killme2008 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 46 minutes and 59 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between f58ed88 and 4cbb4c8.

Walkthrough

The changes introduce a function resolve_addr to handle hostname and port resolution for network addresses. This affects the HeartbeatTask struct in datanode and frontend by using peer_addr instead of server_addr. Configuration files are updated to clarify the usage of hostnames for the gRPC server, enhancing documentation and code reliability. Code cleanliness is improved by removing redundant functions and test cases.

Changes

File Path Change Summary
src/datanode/src/heartbeat.rs Renamed server_addr to peer_addr, used resolve_addr for address resolution, and removed redundant resolve_addr function along with its test cases.
src/frontend/src/heartbeat.rs Similar updates to heartbeat.rs as in datanode, with peer_addr and resolve_addr usages.
src/servers/src/addrs.rs Introduced resolve_addr function and added tests for address resolution logic.
src/servers/src/lib.rs Added the new addrs module to the public scope for use in the project.
config/datanode.example.toml Updated comments to clarify the hostname field’s purpose for the gRPC server in the configuration file.
config/frontend.example.toml Added a new hostname field in the [grpc] section for specifying external host connections and advertisement to metasrv.
config/config.md Clarified the grpc.hostname configuration parameter with additional notes on its purpose and usage.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Datanode
    participant Frontend
    participant Servers as Servers::Addrs

    Client->>+Datanode: Sends request with server name
    Datanode->>+Servers: Resolve address using `resolve_addr`
    Servers-->>-Datanode: Returns `peer_addr`
    Datanode->>Frontend: Communicates with `peer_addr`
    Frontend->>Frontend: Uses resolved address
    Frontend-->>Client: Response with resolved peer information
Loading

Poem

In code’s vast land, a task arose,
With addresses both near and far, they chose.
From server to peer, the change was born,
To resolve with grace each early morn.
Now networks link with clearer sight,
A seamless dance from day to night.

🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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 Jun 24, 2024
@killme2008 killme2008 marked this pull request as ready for review June 24, 2024 20:37
@killme2008 killme2008 requested a review from a team as a code owner June 24, 2024 20:37
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4b42c7b and 56a1cf7.

Files selected for processing (4)
  • src/datanode/src/heartbeat.rs (6 hunks)
  • src/frontend/src/heartbeat.rs (4 hunks)
  • src/servers/src/addrs.rs (1 hunks)
  • src/servers/src/lib.rs (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/servers/src/lib.rs
Additional comments not posted (6)
src/frontend/src/heartbeat.rs (3)

25-25: Import of servers::addrs is appropriate.

This import is required for the updated address resolution logic in HeartbeatTask.


41-41: Correct update of peer_addr in HeartbeatTask.

The update to initialize peer_addr using the resolve_addr function from the addrs module is correctly implemented and aligns with the PR's objectives.

Also applies to: 57-57


57-57: Initialization of HeartbeatTask is correct.

The new method correctly initializes the HeartbeatTask with the updated peer_addr. The rest of the method's logic is appropriate and unchanged.

src/datanode/src/heartbeat.rs (3)

31-31: Import of servers::addrs is appropriate for the datanode.

This import is required for the updated address resolution logic in HeartbeatTask.


51-51: Correct update of peer_addr in HeartbeatTask.

The update to initialize peer_addr using the resolve_addr function from the addrs module is correctly implemented and aligns with the PR's objectives.

Also applies to: 87-87


87-87: Initialization of HeartbeatTask in datanode is correct.

The try_new method correctly initializes the HeartbeatTask with the updated peer_addr. The rest of the method's logic is appropriate and unchanged.

src/servers/src/addrs.rs Show resolved Hide resolved
src/servers/src/addrs.rs Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.56%. Comparing base (cdd4baf) to head (4cbb4c8).
Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4199      +/-   ##
==========================================
- Coverage   85.05%   84.56%   -0.49%     
==========================================
  Files        1031     1041      +10     
  Lines      181276   183023    +1747     
==========================================
+ Hits       154176   154772     +596     
- Misses      27100    28251    +1151     

Copy link
Member

@sunng87 sunng87 left a comment

Choose a reason for hiding this comment

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

We should remove the port part when displaying peer_addr in cluster_info table, because those port serves different purpose, it's meaningless to list them in the same context.

@killme2008
Copy link
Contributor Author

We should remove the port part when displaying peer_addr in cluster_info table, because those port serves different purpose, it's meaningless to list them in the same context.

As I said in #4186 (comment)

I think using gRPC is good currently, and the gRPC is the main communication between nodes, it's part of cluster-info.

@fengjiachun
Copy link
Collaborator

Flow's heartbeat task also need to do the same thing:

pub struct HeartbeatTask {

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 56a1cf7 and d059e91.

Files selected for processing (6)
  • config/datanode.example.toml (1 hunks)
  • config/frontend.example.toml (1 hunks)
  • src/datanode/src/heartbeat.rs (6 hunks)
  • src/frontend/src/heartbeat.rs (4 hunks)
  • src/servers/src/addrs.rs (1 hunks)
  • src/servers/src/lib.rs (1 hunks)
Files skipped from review due to trivial changes (2)
  • config/datanode.example.toml
  • config/frontend.example.toml
Files skipped from review as they are similar to previous changes (3)
  • src/frontend/src/heartbeat.rs
  • src/servers/src/addrs.rs
  • src/servers/src/lib.rs
Additional comments not posted (1)
src/datanode/src/heartbeat.rs (1)

51-51: Validation of the peer_addr initialization.

The peer_addr field in the HeartbeatTask struct is now initialized using the addrs::resolve_addr function. This change aligns with the PR's objective to ensure correct peer addresses are registered. However, ensure that the resolve_addr function is robust and handles edge cases effectively, especially since it involves network configurations which can be tricky.

It would be beneficial to verify that this function has comprehensive unit tests covering various scenarios, including error cases and boundary conditions.

Also applies to: 87-87

src/datanode/src/heartbeat.rs Show resolved Hide resolved
src/datanode/src/heartbeat.rs Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d059e91 and 1b5ee58.

Files selected for processing (1)
  • config/config.md (2 hunks)
Additional context used
LanguageTool
config/config.md

[uncategorized] ~31-~31: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...for Certificate and key file change and auto reload.
For now, gRPC tls config does not ...


[uncategorized] ~31-~31: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...r now, gRPC tls config does not support auto reload. | | mysql | -- | -- | MySQL server o...


[uncategorized] ~40-~40: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...for Certificate and key file change and auto reload | | postgres | -- | -- | PostgresSQL ...


[uncategorized] ~49-~49: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...for Certificate and key file change and auto reload | | opentsdb | -- | -- | OpenTSDB pro...


[grammar] ~93-~93: “Google” is a proper noun and needs to be capitalized. (A_GOOGLE)
Context: ...e| String |None` | The scope of the google cloud storage.
**It's only used whe...


[grammar] ~94-~94: “Google” is a proper noun and needs to be capitalized. (A_GOOGLE)
Context: ...g | None | The credential path of the google cloud storage.
**It's only used whe...


[style] ~134-~134: To form a complete sentence, be sure to include a subject. (MISSING_IT_THERE)
Context: ...vel| String |None| The log level. Can beinfo/debug/warn/error. | | ...


[grammar] ~143-~143: Consider using either the past participle “recommended” or the present participle “recommending” here. (BEEN_PART_AGREEMENT)
Context: ...For standalone mode, self_import is recommend to collect metrics generated by itself ...


[uncategorized] ~179-~179: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...for Certificate and key file change and auto reload.
For now, gRPC tls config does not ...


[uncategorized] ~179-~179: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...r now, gRPC tls config does not support auto reload. | | mysql | -- | -- | MySQL server o...


[uncategorized] ~188-~188: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...for Certificate and key file change and auto reload | | postgres | -- | -- | PostgresSQL ...


[uncategorized] ~197-~197: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...for Certificate and key file change and auto reload | | opentsdb | -- | -- | OpenTSDB pro...


[style] ~221-~221: To form a complete sentence, be sure to include a subject. (MISSING_IT_THERE)
Context: ...vel| String |None| The log level. Can beinfo/debug/warn/error. | | ...


[grammar] ~230-~230: Consider using either the past participle “recommended” or the present participle “recommending” here. (BEEN_PART_AGREEMENT)
Context: ...For standalone mode, self_import is recommend to collect metrics generated by itself ...


[style] ~283-~283: To form a complete sentence, be sure to include a subject. (MISSING_IT_THERE)
Context: ...vel| String |None| The log level. Can beinfo/debug/warn/error. | | ...


[grammar] ~292-~292: Consider using either the past participle “recommended” or the present participle “recommending” here. (BEEN_PART_AGREEMENT)
Context: ...For standalone mode, self_import is recommend to collect metrics generated by itself ...


[uncategorized] ~326-~326: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...for Certificate and key file change and auto reload.
For now, gRPC tls config does not ...


[uncategorized] ~326-~326: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’). (AUTO_HYPHEN)
Context: ...r now, gRPC tls config does not support auto reload. | | runtime | -- | -- | The runtime ...


[grammar] ~374-~374: “Google” is a proper noun and needs to be capitalized. (A_GOOGLE)
Context: ...e| String |None` | The scope of the google cloud storage.
**It's only used whe...


[grammar] ~375-~375: “Google” is a proper noun and needs to be capitalized. (A_GOOGLE)
Context: ...g | None | The credential path of the google cloud storage.
**It's only used whe...


[style] ~415-~415: To form a complete sentence, be sure to include a subject. (MISSING_IT_THERE)
Context: ...vel| String |None| The log level. Can beinfo/debug/warn/error. | | ...


[grammar] ~424-~424: Consider using either the past participle “recommended” or the present participle “recommending” here. (BEEN_PART_AGREEMENT)
Context: ...For standalone mode, self_import is recommend to collect metrics generated by itself ...

Markdownlint
config/config.md

5-5: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


6-6: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


7-7: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


151-151: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


238-238: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


300-300: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


37-37: null (MD034, no-bare-urls)
Bare URL used


185-185: null (MD034, no-bare-urls)
Bare URL used


247-247: null (MD034, no-bare-urls)
Bare URL used

Additional comments not posted (2)
config/config.md (2)

173-173: Clarification Added for grpc.hostname

The added comments for the grpc.hostname field enhance understanding by clearly stating its purpose for external connections and service advertisement. This is a positive change for clarity and usability.


318-318: Consistent Clarification Across Configurations

Similar to the previous comment, the clarification added to the grpc.hostname in the Datanode section maintains consistency and enhances user understanding of the configuration's purpose.
[APROVED]

@sunng87 sunng87 requested a review from zyy17 June 25, 2024 08:29
@sunng87
Copy link
Member

sunng87 commented Jun 25, 2024

@zyy17 In our operator, we will need to pass hostname argument to frontend after this patch merged.

src/servers/src/addrs.rs Outdated Show resolved Hide resolved
src/servers/src/addrs.rs Outdated Show resolved Hide resolved
@killme2008
Copy link
Contributor Author

@fengjiachun @sunng87 @v0y4g3r Please take another look.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1b5ee58 and f58ed88.

Files selected for processing (1)
  • src/servers/src/addrs.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/servers/src/addrs.rs

@fengjiachun
Copy link
Collaborator

Flow's heartbeat task also need to do the same thing:

pub struct HeartbeatTask {

Another heartbeat task, it is for flow engine. @killme2008

@killme2008
Copy link
Contributor Author

Flow's heartbeat task also need to do the same thing:

pub struct HeartbeatTask {

Another heartbeat task, it is for flow engine. @killme2008

Fixed

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

@sunng87 sunng87 added this pull request to the merge queue Jun 26, 2024
Merged via the queue into GreptimeTeam:main with commit a779cb3 Jun 26, 2024
57 checks passed
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