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(servers): make http timeout and body limit optional #4217

Merged
merged 3 commits into from
Jun 26, 2024

Conversation

fengjiachun
Copy link
Collaborator

@fengjiachun fengjiachun commented Jun 26, 2024

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?

Set timeout or body limit to 0 to disable them.

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 the ability to disable HTTP timeout by setting http.timeout to 0.
    • Added the ability to disable HTTP body limit by setting http.body_limit to 0.
  • Improvements
    • Enhanced flexibility in HTTP server configuration by allowing zero values for timeout and body limits, providing more control over server behavior.

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
@fengjiachun fengjiachun requested a review from a team as a code owner June 26, 2024 04:12
Copy link
Contributor

coderabbitai bot commented Jun 26, 2024

Walkthrough

The recent updates enhance the HTTP server configuration options, allowing more flexibility by enabling the timeout and body limit settings to be disabled by setting their values to 0. This change affects configuration files and the HTTP server's implementation, providing improved configurability and control.

Changes

Files Change Summary
config/config.md Updated http.timeout and http.body_limit to allow disabling by setting to 0.
config/frontend.example.toml Modified timeout and body_limit settings to reflect disabling by setting to 0.
config/standalone.example.toml Adjusted timeout and body_limit settings to allow disabling by setting to 0.
src/servers/src/http.rs Enhanced build method in HttpServer to conditionally create timeout_layer and body_limit_layer based on server options.

Poem

Amidst configs and code's endless flight,
We grant more freedom to HTTP's might.
Disable the limits, let requests run free,
In zero we trust, simplicity we see.
Our code now blossoms, our servers stand tall,
For now, constraints shall no longer enthrall.


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 26, 2024
@fengjiachun fengjiachun changed the title chore: make config chore: set http timeout or body limit to 0 to disable them. Jun 26, 2024
@fengjiachun fengjiachun changed the title chore: set http timeout or body limit to 0 to disable them. feat(servers): make http timeout and body limit optional Jun 26, 2024
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 948c869 and 4d18fc3.

Files selected for processing (4)
  • config/config.md (2 hunks)
  • config/frontend.example.toml (1 hunks)
  • config/standalone.example.toml (1 hunks)
  • src/servers/src/http.rs (1 hunks)
Files skipped from review due to trivial changes (1)
  • config/standalone.example.toml
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...


[uncategorized] ~108-~108: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: .... If not set, it's default to 1/8 of OS memory with a max limitation of 1GB. | | `regi...


[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] ~178-~178: 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] ~178-~178: 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] ~187-~187: 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] ~196-~196: 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] ~220-~220: 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] ~229-~229: 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] ~282-~282: 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] ~291-~291: 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] ~325-~325: 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] ~325-~325: 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] ~373-~373: “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] ~374-~374: “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...


[uncategorized] ~388-~388: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: .... If not set, it's default to 1/8 of OS memory with a max limitation of 1GB. | | `regi...


[style] ~414-~414: 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] ~423-~423: 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


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


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


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


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


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

Additional comments not posted (3)
config/frontend.example.toml (2)

29-29: Clarification on timeout setting.

The comment "Set to 0 to disable timeout." is clear and directly informs users of the new functionality. This is a significant improvement for flexibility in configuration.


33-33: Clarification on body limit setting.

The addition of "Set to 0 to disable limit." enhances user control over HTTP request body size, aligning with the changes described in the summary. This update is valuable for environments where large or unrestricted body sizes are necessary.

src/servers/src/http.rs (1)

673-688: Review of dynamic layer configuration in HTTP server build method.

The conditional creation of timeout_layer and body_limit_layer based on the server options is a robust design choice. It allows for greater flexibility and customization of server behavior based on configuration values. The use of ServiceBuilder to conditionally apply these layers is a clean and effective implementation. However, ensure that the logging statements provide enough information for debugging purposes.

config/config.md Outdated Show resolved Hide resolved
config/config.md Outdated 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 4d18fc3 and 863e591.

Files selected for processing (3)
  • config/config.md (2 hunks)
  • config/frontend.example.toml (1 hunks)
  • config/standalone.example.toml (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • config/frontend.example.toml
  • config/standalone.example.toml
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...


[uncategorized] ~108-~108: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: .... If not set, it's default to 1/8 of OS memory with a max limitation of 1GB. | | `regi...


[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] ~178-~178: 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] ~178-~178: 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] ~187-~187: 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] ~196-~196: 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] ~220-~220: 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] ~229-~229: 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] ~282-~282: 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] ~291-~291: 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] ~325-~325: 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] ~325-~325: 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] ~373-~373: “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] ~374-~374: “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...


[uncategorized] ~388-~388: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: .... If not set, it's default to 1/8 of OS memory with a max limitation of 1GB. | | `regi...


[style] ~414-~414: 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] ~423-~423: 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


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


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


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


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


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

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

22-22: Updated HTTP timeout configuration documentation

The documentation now clearly specifies that setting the http.timeout to 0 disables the timeout. This is a crucial update for users who need flexible configuration, especially in environments where timeouts may not be desired.


23-23: Enhanced HTTP body limit configuration

The update to http.body_limit includes detailed support for various units and the option to disable the limit by setting it to 0. This enhancement not only improves usability but also aligns with the need for more dynamic server configurations.


169-169: Consistency in HTTP timeout configuration across modes

The addition of disabling the timeout feature in the Distributed Mode section ensures consistency across different operational modes, which is beneficial for maintaining uniform behavior across deployments.


170-170: Unified approach to HTTP body limit settings

Similar to the standalone mode, the distributed mode now also supports the detailed specification of units for http.body_limit and the ability to disable it. This uniformity across configurations is excellent for user experience and system administration.

Copy link

codecov bot commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 69.23077% with 4 lines in your changes missing coverage. Please review.

Project coverage is 84.56%. Comparing base (948c869) to head (863e591).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4217      +/-   ##
==========================================
- Coverage   84.85%   84.56%   -0.29%     
==========================================
  Files        1040     1040              
  Lines      183023   183028       +5     
==========================================
- Hits       155297   154782     -515     
- Misses      27726    28246     +520     

@waynexia waynexia enabled auto-merge June 26, 2024 05:35
@waynexia waynexia added this pull request to the merge queue Jun 26, 2024
Merged via the queue into GreptimeTeam:main with commit df0fff2 Jun 26, 2024
59 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.

3 participants