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: build info should use build time env var #4343

Merged
merged 6 commits into from
Jul 12, 2024

Conversation

tisonkun
Copy link
Contributor

@tisonkun tisonkun commented Jul 10, 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?

This closes #4331

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

  • Bug Fixes
    • Updated SQL queries to improve hash value matching, now supporting 7 to 8 character lengths.
    • Renamed the git_dirty field to git_clean in information_schema.build_info for clarity.
    • Changed placeholder value from "dirty" to "clean" in SQL query results.

Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun tisonkun requested a review from a team as a code owner July 10, 2024 23:41
Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Walkthrough

The changes primarily involve updating SQL scripts and result files to modify the representation of hash values and the build information in GreptimeDB. The hash patterns are adjusted to allow 7 to 8 characters, and the git_dirty field is renamed to git_clean to reflect cleaner build status.

Changes

Files Change Summary
tests/cases/.../information_schema/cluster_info.{result,sql} Updated regex patterns to match hashes of 7-8 characters instead of exactly 7
tests/cases/standalone/common/function/system.{result,sql} Changed placeholder value from "dirty" to "clean" in SQL query and result files
tests/cases/standalone/common/system/information_schema.result Renamed field git_dirty to git_clean in the information_schema.build_info

Assessment against linked issues

Objective Addressed Explanation
Should not use BuildInfo but rely on build time env (#4331)
Update regex pattern for hash values to allow 7-8 characters (#4331)

Poem

In the code where hashes roam,
Now they stretch and freely roam,
Seven to eight, they now align,
With clean builds that brightly shine.
GreptimeDB, in lines so clear,
Our changes bring new cheer, oh dear!

Tip

You can customize the tone of the comments in your PRs

Specify the tone of the comments in your PRs by configuring the tone-instructions setting in your project's settings in CodeRabbit.


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 Jul 10, 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between da0c840 and d8d2e2c.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (19)
  • src/catalog/src/information_schema/memory_table/tables.rs (2 hunks)
  • src/client/Cargo.toml (1 hunks)
  • src/cmd/Cargo.toml (1 hunks)
  • src/cmd/src/bin/greptime.rs (1 hunks)
  • src/cmd/src/datanode.rs (3 hunks)
  • src/cmd/src/flownode.rs (1 hunks)
  • src/cmd/src/frontend.rs (1 hunks)
  • src/cmd/src/metasrv.rs (2 hunks)
  • src/cmd/src/standalone.rs (1 hunks)
  • src/common/greptimedb-telemetry/Cargo.toml (2 hunks)
  • src/common/greptimedb-telemetry/src/lib.rs (4 hunks)
  • src/common/substrait/Cargo.toml (1 hunks)
  • src/common/version/Cargo.toml (1 hunks)
  • src/common/version/build.rs (1 hunks)
  • src/common/version/src/lib.rs (2 hunks)
  • src/servers/build.rs (2 hunks)
  • src/servers/src/http/handler.rs (2 hunks)
  • src/servers/src/http/prometheus.rs (3 hunks)
  • src/servers/tests/http/http_handler_test.rs (1 hunks)
Files skipped from review due to trivial changes (8)
  • src/client/Cargo.toml
  • src/cmd/src/bin/greptime.rs
  • src/cmd/src/flownode.rs
  • src/cmd/src/frontend.rs
  • src/cmd/src/metasrv.rs
  • src/common/greptimedb-telemetry/Cargo.toml
  • src/common/substrait/Cargo.toml
  • src/servers/build.rs
Additional comments not posted (24)
src/common/version/Cargo.toml (2)

14-15: Dependency Additions Look Good.

The added dependencies (const_format and shadow-rs) are relevant to the changes described in the PR.


20-21: Build Dependency Addition Looks Good.

The added build dependency (build-data) is relevant to the changes described in the PR.

src/common/version/build.rs (2)

15-15: Import Additions Look Good.

The added imports (format_timestamp and get_source_time) from build_data are relevant to the changes described in the PR.


17-28: Main Function Updates Look Good.

The changes in the main function correctly set the BUILD_TIMESTAMP and use shadow_rs to handle build information.

src/cmd/Cargo.toml (1)

86-86: Dependency Move Looks Good.

The move of common-version from [build-dependencies] to [dev-dependencies] is relevant to the changes described in the PR.

src/common/version/src/lib.rs (8)

1-5: Import and Macro Invocation Look Good.

The import of Display and the invocation of shadow_rs::shadow!(build) are relevant to the changes described in the PR.


9-17: BuildInfo Struct Modifications Look Good.

The changes to the BuildInfo struct fields from Cow<'static, str> to &'static str are appropriate and improve the design.


37-52: OwnedBuildInfo Struct Addition Looks Good.

The addition of the OwnedBuildInfo struct is well-designed and relevant to the changes described in the PR.


54-67: From Implementation for OwnedBuildInfo Looks Good.

The implementation of From<BuildInfo> for OwnedBuildInfo is correctly done and relevant to the changes described in the PR.


70-84: Display Implementation for OwnedBuildInfo Looks Good.

The implementation of Display for OwnedBuildInfo is correctly done and relevant to the changes described in the PR.


87-99: build_info Function Updates Look Good.

The updates to the build_info function to return a BuildInfo instance directly are well-designed and relevant to the changes described in the PR.


103-110: version Function Addition Looks Good.

The addition of the version function to provide a formatted version string is well-designed and relevant to the changes described in the PR.


113-114: short_version Function Addition Looks Good.

The addition of the short_version function to provide a short version string is well-designed and relevant to the changes described in the PR.

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

313-320: LGTM! Ensure the new build information is correct.

The status function now correctly retrieves build information from the common_version::build_info module. This change aligns with the PR's objective to use build time environment variables.

src/common/greptimedb-telemetry/src/lib.rs (2)

118-118: LGTM! Ensure the new build information is correct.

The get_version method now correctly retrieves the version from the common_version::build_info module. This change aligns with the PR's objective to use build time environment variables.


122-122: LGTM! Ensure the new build information is correct.

The get_git_hash method now correctly retrieves the commit hash from the common_version::build_info module. This change aligns with the PR's objective to use build time environment variables.

src/catalog/src/information_schema/memory_table/tables.rs (2)

83-83: Ensure the new build information is correct.

The get_schema_columns function now correctly retrieves build information from the common_version::build_info module and replaces the GIT_DIRTY field with GIT_CLEAN. This change aligns with the PR's objective to use build time environment variables.


92-92: Ensure the new build information is correct.

The get_schema_columns function now correctly retrieves build information from the common_version::build_info module and replaces the GIT_DIRTY field with GIT_CLEAN. This change aligns with the PR's objective to use build time environment variables.

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

571-578: LGTM! Ensure the new build information is correct.

The test_status function now correctly retrieves build information from the common_version::build_info module. This change aligns with the PR's objective to use build time environment variables.

src/cmd/src/datanode.rs (1)

269-269: LGTM!

The change to replace macro calls with function calls is approved. This enhances consistency and reliability.

src/cmd/src/standalone.rs (1)

416-416: LGTM!

The change to replace macro calls with function calls is approved. This enhances consistency and reliability.

src/servers/src/http/prometheus.rs (3)

29-29: LGTM!

The import update to use OwnedBuildInfo is approved. This aligns with the updated struct usage.


103-103: LGTM!

The update to use OwnedBuildInfo in the PrometheusResponse enum is approved. This aligns with the updated struct usage.


151-151: LGTM!

The update to use OwnedBuildInfo in the build_info_query function is approved. This aligns with the updated struct usage.

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 d8d2e2c and d15c88e.

Files selected for processing (1)
  • src/common/version/src/lib.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/common/version/src/lib.rs

Signed-off-by: tison <wander4096@gmail.com>
Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 74.28571% with 18 lines in your changes missing coverage. Please review.

Project coverage is 84.90%. Comparing base (da0c840) to head (9f62805).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4343      +/-   ##
==========================================
- Coverage   85.18%   84.90%   -0.28%     
==========================================
  Files        1060     1060              
  Lines      189069   189076       +7     
==========================================
- Hits       161057   160539     -518     
- Misses      28012    28537     +525     

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 d15c88e and 375b23e.

Files selected for processing (4)
  • src/common/version/Cargo.toml (1 hunks)
  • src/common/version/src/lib.rs (2 hunks)
  • tests/cases/standalone/common/function/system.result (1 hunks)
  • tests/cases/standalone/common/system/information_schema.result (2 hunks)
Files skipped from review due to trivial changes (1)
  • tests/cases/standalone/common/function/system.result
Files skipped from review as they are similar to previous changes (2)
  • src/common/version/Cargo.toml
  • src/common/version/src/lib.rs
Additional comments not posted (2)
tests/cases/standalone/common/system/information_schema.result (2)

581-581: LGTM! But verify the consistency of the field name change.

The field git_dirty has been correctly renamed to git_clean. Ensure this change is consistently applied across the codebase.

#!/bin/bash
# Description: Verify consistency of the field name change from `git_dirty` to `git_clean`.

# Test: Search for occurrences of `git_dirty` to ensure they are all updated.
rg --type sql --type rust -w 'git_dirty'

56-56: LGTM! But verify the consistency of the field name change.

The field git_dirty has been correctly renamed to git_clean. Ensure this change is consistently applied across the codebase.

Verification successful

Verified: The field name change from git_dirty to git_clean is consistent within the provided context.

  • The field git_dirty is no longer present in the codebase.
  • The field git_clean appears correctly in the tests/cases/standalone/common/system/information_schema.result file.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of the field name change from `git_dirty` to `git_clean`.

# Test: Search for occurrences of `git_dirty` to ensure they are all updated.
rg --type sql --type rust -w 'git_dirty'

Length of output: 40


Script:

#!/bin/bash
# Description: Verify consistency of the field name change to `git_clean`.

# Test: Search for occurrences of `git_clean` to ensure it is correctly used.
rg --type sql --type rust -w 'git_clean'

Length of output: 40


Script:

#!/bin/bash
# Description: Verify consistency of the field name change from `git_dirty` to `git_clean`.

# Test: Search for occurrences of `git_dirty` and `git_clean` across the entire codebase to ensure the changes are applied consistently.
rg -w 'git_dirty'
rg -w 'git_clean'

Length of output: 704

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

Outside diff range, codebase verification and nitpick comments (1)
tests/cases/standalone/information_schema/cluster_info.result (1)

22-22: Inconsistent regex patterns for hash values.

The file tests/cases/standalone/information_schema/cluster_info.result contains inconsistent regex patterns for hash values: \s[a-z0-9]{7,8}\s and \s[a-z0-9]{7}\s. Ensure uniformity in the regex pattern used for hash values.

  • tests/cases/standalone/information_schema/cluster_info.result
Analysis chain

Verify the regex pattern update.

The regex pattern for matching hash values was changed to allow 7 to 8 alphanumeric characters. Ensure this change is consistent and aligns with the expected output.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the updated regex pattern is consistent across the file.

# Test: Search for the regex pattern updates. Expect: Consistent pattern for hash values.
rg --type text 'SQLNESS REPLACE (\s[a-z0-9]{7,8}\s)'

Length of output: 83


Script:

#!/bin/bash
# Description: Verify the updated regex pattern is consistent across the file.

# Test: Search for the regex pattern updates. Expect: Consistent pattern for hash values.
rg 'SQLNESS REPLACE (\s[a-z0-9]{7,8}\s)'

Length of output: 42


Script:

#!/bin/bash
# Description: Verify the presence of any "SQLNESS REPLACE" patterns in the file.

# Test: Search for the "SQLNESS REPLACE" pattern. Expect: Identify any similar patterns.
rg 'SQLNESS REPLACE'

Length of output: 35464

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 375b23e and e17de1f.

Files selected for processing (3)
  • tests/cases/standalone/common/function/system.result (1 hunks)
  • tests/cases/standalone/common/system/information_schema.result (2 hunks)
  • tests/cases/standalone/information_schema/cluster_info.result (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • tests/cases/standalone/common/function/system.result
  • tests/cases/standalone/common/system/information_schema.result
Additional comments not posted (1)
tests/cases/standalone/information_schema/cluster_info.result (1)

Line range hint 1-54:
Review the SQL statements and expected outputs.

Ensure the SQL statements and expected outputs are correct and complete. The regex pattern changes should align with the expected results.

Verification successful

Ensure the SQL statements and expected outputs are correct and complete.

  • The SQL statements and expected outputs in tests/cases/standalone/information_schema/cluster_info.result are present and align with the regex replacements.
  • The regex replacements in the comments should be consistent with the expected results.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the SQL statements and expected outputs are correct and complete.

# Test: Search for the SQL statements and expected outputs.
rg --type text 'SELECT \* FROM CLUSTER_INFO'

Length of output: 75


Script:

#!/bin/bash
# Search for the SQL statements and expected outputs.
rg 'SELECT \* FROM CLUSTER_INFO'

Length of output: 2412

Signed-off-by: tison <wander4096@gmail.com>
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 e17de1f and 9f62805.

Files selected for processing (7)
  • tests/cases/distributed/information_schema/cluster_info.result (5 hunks)
  • tests/cases/distributed/information_schema/cluster_info.sql (1 hunks)
  • tests/cases/standalone/common/function/system.result (1 hunks)
  • tests/cases/standalone/common/function/system.sql (1 hunks)
  • tests/cases/standalone/common/system/information_schema.result (2 hunks)
  • tests/cases/standalone/information_schema/cluster_info.result (3 hunks)
  • tests/cases/standalone/information_schema/cluster_info.sql (2 hunks)
Files skipped from review due to trivial changes (3)
  • tests/cases/distributed/information_schema/cluster_info.result
  • tests/cases/distributed/information_schema/cluster_info.sql
  • tests/cases/standalone/common/function/system.sql
Files skipped from review as they are similar to previous changes (3)
  • tests/cases/standalone/common/function/system.result
  • tests/cases/standalone/common/system/information_schema.result
  • tests/cases/standalone/information_schema/cluster_info.result
Additional comments not posted (3)
tests/cases/standalone/information_schema/cluster_info.sql (3)

7-7: Regular expression pattern update looks good.

The change to match 7 or 8 characters for hash values is appropriate and aligns with the goal of ensuring accurate build information retrieval.


15-15: Regular expression pattern update looks good.

The change to match 7 or 8 characters for hash values is appropriate and aligns with the goal of ensuring accurate build information retrieval.


25-25: Regular expression pattern update looks good.

The change to match 7 or 8 characters for hash values is appropriate and aligns with the goal of ensuring accurate build information retrieval.

Copy link
Contributor

@evenyag evenyag 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
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

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

LGTM

@killme2008 killme2008 added this pull request to the merge queue Jul 12, 2024
Merged via the queue into GreptimeTeam:main with commit 285ffc5 Jul 12, 2024
55 checks passed
@tisonkun tisonkun deleted the fixup-build-info branch July 12, 2024 16:18
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.

Should not use BuildInfo but rely on build time env
3 participants