Skip to content

This PR is to add comment to WithTieredStore in fluid/pkg/ddc/base/runtime.go#5728

Closed
0x001cdf2c wants to merge 1 commit intofluid-cloudnative:masterfrom
0x001cdf2c:my_fluid
Closed

This PR is to add comment to WithTieredStore in fluid/pkg/ddc/base/runtime.go#5728
0x001cdf2c wants to merge 1 commit intofluid-cloudnative:masterfrom
0x001cdf2c:my_fluid

Conversation

@0x001cdf2c
Copy link
Copy Markdown
Contributor

Ⅰ. Describe what this PR does
This PR is to add comment to WithTieredStore in fluid/pkg/ddc/base/runtime.go
Ⅱ. Does this pull request fix one issue?
fixes #5727
Ⅲ. Special notes for reviews
ADD comments

Signed-off-by: TangSZ <2814576801@qq.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving code clarity and maintainability by adding detailed documentation to a critical function. The newly added comment provides an in-depth explanation of a complex data structure conversion process, ensuring that future developers can easily understand its functionality and underlying rationale.

Highlights

  • Documentation: Added a comprehensive comment to the WithTieredStore function in pkg/ddc/base/runtime.go. This comment details the conversion logic from datav1alpha1.TieredStore to TieredStoreInfo, explaining the purpose, steps, and error handling for this conversion.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented Mar 26, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign cheyang for approval by writing /assign @cheyang in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented Mar 26, 2026

Hi @0x001cdf2c. Thanks for your PR.

I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a detailed comment block to the WithTieredStore function in pkg/ddc/base/runtime.go, explaining its purpose in converting datav1alpha1.TieredStore to TieredStoreInfo and outlining the conversion logic. The feedback suggests that this comment is overly verbose for a wrapper function and includes implementation details that would be better placed with the convertToTieredstoreInfo function, recommending a more concise summary for WithTieredStore to align with Go's style guide for comments.

Comment thread pkg/ddc/base/runtime.go
Comment on lines +249 to +260
// WithTieredStore converts datav1alpha1.TieredStore to TieredStoreInfo and sets it to RuntimeInfo
// The conversion is needed because datav1alpha1.TieredStore contains some fields in string type which are not convenient to use, such as Quota and QuotaList, and we want to convert them to more structured type in RuntimeInfo.
// The conversion logic is as follows:
// 1. If the length of Levels in datav1alpha1.TieredStore is 0, return an empty TieredStoreInfo.
// 2. For each level in datav1alpha1.TieredStore, split the Path by comma to get multiple paths.
// 3. If QuotaList is not set, divide Quota equally to multiple paths and set the quota for each path.
// 4. If QuotaList is set, split the QuotaList by comma to get multiple quotas, and set the corresponding quota for each path. The value in QuotaList will overwrite the value in Quota if both of them are set.
// 5. Set other fields in TieredStoreInfo according to the values in datav1alpha1.TieredStore.
// If there is any error during the conversion, return the error.
// For example, if the length of quotas in QuotaList is not consistent with the length of paths, return an error. If the quota in Quota or QuotaList can't be parsed to a quantity type, return an error.
// The reason why we want to convert datav1alpha1.TieredStore to TieredStoreInfo instead of using datav1alpha1.TieredStore directly in RuntimeInfo is that datav1alpha1.TieredStore is designed for users to input the tiered store configuration in a flexible way, while TieredStoreInfo is designed for us to use the tiered store configuration in a more structured way in the code. By converting datav1alpha1.TieredStore to TieredStoreInfo, we can make it easier for us to use the tiered store configuration in the code, and also make it easier for us to validate the tiered store configuration when we convert it.
// The conversion logic is implemented in the convertToTieredstoreInfo function, and WithTieredStore is a wrapper of it to set the converted TieredStoreInfo to RuntimeInfo.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

While adding comments is great for code clarity, this comment block is quite verbose for a wrapper function and includes implementation details of convertToTieredstoreInfo. According to Go's style guide, comments should be concise and located with the code they describe.

It would be better to move the detailed conversion logic to a comment block for the convertToTieredstoreInfo function. For WithTieredStore, a more concise summary is preferable.

Here is a suggested replacement that is more idiomatic for Go documentation:

Suggested change
// WithTieredStore converts datav1alpha1.TieredStore to TieredStoreInfo and sets it to RuntimeInfo
// The conversion is needed because datav1alpha1.TieredStore contains some fields in string type which are not convenient to use, such as Quota and QuotaList, and we want to convert them to more structured type in RuntimeInfo.
// The conversion logic is as follows:
// 1. If the length of Levels in datav1alpha1.TieredStore is 0, return an empty TieredStoreInfo.
// 2. For each level in datav1alpha1.TieredStore, split the Path by comma to get multiple paths.
// 3. If QuotaList is not set, divide Quota equally to multiple paths and set the quota for each path.
// 4. If QuotaList is set, split the QuotaList by comma to get multiple quotas, and set the corresponding quota for each path. The value in QuotaList will overwrite the value in Quota if both of them are set.
// 5. Set other fields in TieredStoreInfo according to the values in datav1alpha1.TieredStore.
// If there is any error during the conversion, return the error.
// For example, if the length of quotas in QuotaList is not consistent with the length of paths, return an error. If the quota in Quota or QuotaList can't be parsed to a quantity type, return an error.
// The reason why we want to convert datav1alpha1.TieredStore to TieredStoreInfo instead of using datav1alpha1.TieredStore directly in RuntimeInfo is that datav1alpha1.TieredStore is designed for users to input the tiered store configuration in a flexible way, while TieredStoreInfo is designed for us to use the tiered store configuration in a more structured way in the code. By converting datav1alpha1.TieredStore to TieredStoreInfo, we can make it easier for us to use the tiered store configuration in the code, and also make it easier for us to validate the tiered store configuration when we convert it.
// The conversion logic is implemented in the convertToTieredstoreInfo function, and WithTieredStore is a wrapper of it to set the converted TieredStoreInfo to RuntimeInfo.
// WithTieredStore is a RuntimeInfoOption that converts a datav1alpha1.TieredStore to a TieredStoreInfo
// and sets it on the RuntimeInfo.
//
// The datav1alpha1.TieredStore is a user-facing API object that uses strings for flexibility (e.g., QuotaList).
// The internal TieredStoreInfo uses structured types for easier processing and validation.
// This function is a wrapper around convertToTieredstoreInfo, which performs the actual conversion.
References
  1. Go's 'Effective Go' guide recommends that comments should be concise and document the code they are placed with. Long, detailed comments about a wrapped function's implementation are better placed with the function itself to improve code readability and maintainability. (link)

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.22%. Comparing base (b347428) to head (f7117fc).
⚠️ Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
pkg/ddc/base/runtime.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5728   +/-   ##
=======================================
  Coverage   61.22%   61.22%           
=======================================
  Files         444      444           
  Lines       30557    30557           
=======================================
  Hits        18710    18710           
  Misses      10307    10307           
  Partials     1540     1540           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@0x001cdf2c 0x001cdf2c closed this Mar 26, 2026
@0x001cdf2c 0x001cdf2c reopened this Mar 26, 2026
@sonarqubecloud
Copy link
Copy Markdown

@0x001cdf2c 0x001cdf2c closed this Mar 26, 2026
@0x001cdf2c 0x001cdf2c deleted the my_fluid branch March 26, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Comments to WithTieredStore in fluid/pkg/ddc/base/runtime.go

1 participant