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: Support automatic DNS lookup for kafka bootstrap servers #3379

Merged
merged 14 commits into from
Feb 29, 2024

Conversation

J0HN50N133
Copy link
Contributor

@J0HN50N133 J0HN50N133 commented Feb 25, 2024

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

Support automatic DNS lookup for kafka bootstrap servers.

Checklist

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

Refer to a related PR or issue link

This fixes #3328

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Feb 25, 2024
@J0HN50N133
Copy link
Contributor Author

@niebayes @tisonkun Hey, I've implemented #3328 naively. I'm not sure whether I should handle the deserialization error with snafu. And do we need a way to test toml deserializaton more elegantly?

Copy link
Contributor

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

@niebayes I wonder if we should resolve/lookup endpoints on deserialization. It looks more reasonable to resolve/lookup at ClientManager::try_new, i.e., when we're building the connection.

Copy link

codecov bot commented Feb 25, 2024

Codecov Report

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

Project coverage is 84.54%. Comparing base (1f1d1b4) to head (3b9c26a).
Report is 31 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3379      +/-   ##
==========================================
- Coverage   85.58%   84.54%   -1.04%     
==========================================
  Files         892      899       +7     
  Lines      146543   148952    +2409     
==========================================
+ Hits       125413   125926     +513     
- Misses      21130    23026    +1896     

@niebayes
Copy link
Contributor

niebayes commented Feb 26, 2024

@J0HN50N133 Hi, I've read through your code. It's great. However, I agree with @tisonkun that it's better to perform DNS lookup upon building a Kafka client. Apologize for my previous silly suggestion :).

You can browse over the ClientBuilder struct in our codebase and come up with an appropriate solution on DNS lookup. You are supposed to focus on the topic_manager.rs and client_manager.rs files.

@niebayes niebayes self-requested a review February 26, 2024 03:56
@J0HN50N133
Copy link
Contributor Author

@niebayes I've implemented it without introduce any new crate.

@tisonkun
Copy link
Contributor

@J0HN50N133 Please try to avoid delete comments which can increase confusions.

You can hide your own comments or edit in place.

Copy link
Contributor

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

Generally looks good.

@J0HN50N133 @niebayes seems the chaneges are quite duplicate, can we reduce this dup?

@J0HN50N133
Copy link
Contributor Author

Generally looks good.

@J0HN50N133 @niebayes seems the chaneges are quite duplicate, can we reduce this dup?

I was trying to find a way, but topic_manager.rs and client_manager.rs belong to different crates. I don't know where to put the function to share it and handle the error.

@tisonkun
Copy link
Contributor

I wonder if we can have a gtkafka crate wrap rskafka for our utilities. But I don't know if we share so many code and worth it. Or we just duplicate a small range of code.

Wait for the original author @niebayes's suggestion. I'm OK with current duplication level.

src/log-store/src/error.rs Outdated Show resolved Hide resolved
src/log-store/src/kafka/client_manager.rs Outdated Show resolved Hide resolved
@niebayes
Copy link
Contributor

@J0HN50N133 Hi, I've post some review comments. Resolve them and we'll merge your PR ASAP.

@niebayes niebayes assigned niebayes and J0HN50N133 and unassigned niebayes Feb 27, 2024
@niebayes
Copy link
Contributor

niebayes commented Feb 27, 2024

@J0HN50N133 Hi, your code look great and work well. However, greptimedb keeps a conservative attitude towards introducing new dependencies, and since the mockall crate is being introduced for the first time into greptimedb, we will review your code with extra caution.
On the other hand, generic mock crates may potentially generate unnecessary code during compilation, leading to increased build times. Therefore, we opt for simpler testing methods. I have added some suggestions which you can refer to.

src/common/wal/src/lib.rs Outdated Show resolved Hide resolved
src/common/wal/src/lib.rs Outdated Show resolved Hide resolved
src/common/wal/src/error.rs Show resolved Hide resolved
@J0HN50N133
Copy link
Contributor Author

@J0HN50N133 Hi, your code look great and work well. However, greptimedb keeps a conservative attitude towards introducing new dependencies, and since the mockall crate is being introduced for the first time into greptimedb, we will review your code with extra caution. On the other hand, generic mock crates may potentially generate unnecessary code during compilation, leading to increased build times. Therefore, we opt for simpler testing methods. I have added some suggestions which you can refer to.

Actually, I didn't introduce mockall. It already exists in the workspace Cargo.toml.

@niebayes
Copy link
Contributor

@J0HN50N133 Sorry, I've searched the codebase and found another usage of the mockall crate. However, it's still not recommended to use the mockall crate here, since it's too heavy for writing such a simple unit test. Let'
s keep code simpler.

@J0HN50N133
Copy link
Contributor Author

J0HN50N133 commented Feb 29, 2024

@niebayes I've simplified the implementation.

src/common/wal/Cargo.toml Outdated Show resolved Hide resolved
src/common/wal/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@niebayes niebayes left a comment

Choose a reason for hiding this comment

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

LGTM

tisonkun and others added 2 commits February 29, 2024 14:53
Co-authored-by: niebayes <niebayes@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun tisonkun added this pull request to the merge queue Feb 29, 2024
@niebayes
Copy link
Contributor

@J0HN50N133 Thank you very much for your contribution! Your code has been successfully merged into the greptimedb project. We believe that it will operate reliably across thousands of servers and vehicles. We appreciate your valuable contribution, and please continue to stay engaged with the greptimedb community.

Merged via the queue into GreptimeTeam:main with commit a500252 Feb 29, 2024
16 of 17 checks passed
@J0HN50N133
Copy link
Contributor Author

@niebayes @tisonkun Thanks for your patient and help. I would like to make more contribution, could you give me some advice?

@niebayes
Copy link
Contributor

niebayes commented Mar 1, 2024

@J0HN50N133 Take a look at our roadmap 2024.

@tisonkun
Copy link
Contributor

tisonkun commented Mar 1, 2024

FWIW there is an issue for it -

Also, @J0HN50N133 you can check other good first issue in https://github.com/GreptimeTeam/greptimedb/contribute.

@tisonkun
Copy link
Contributor

tisonkun commented Mar 1, 2024

@J0HN50N133 If you can share a bit about your background, interests, and goals, I can tag you when I find issues that would be suitable for you. If you don't want to share it publicly, feel free to drop an email to tison@apache.org.

@J0HN50N133 J0HN50N133 deleted the add_automatic_dns_lookup branch July 31, 2024 13:09
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.

Support automatic DNS lookup for kafka bootstrap servers
3 participants