Skip to content

This PR is to add comments to CachedState in fluid/pkg/ddc/alluxio/operations/cached.go#5941

Open
YifeiZhang0508 wants to merge 1 commit into
fluid-cloudnative:masterfrom
YifeiZhang0508:master
Open

This PR is to add comments to CachedState in fluid/pkg/ddc/alluxio/operations/cached.go#5941
YifeiZhang0508 wants to merge 1 commit into
fluid-cloudnative:masterfrom
YifeiZhang0508:master

Conversation

@YifeiZhang0508
Copy link
Copy Markdown

cached.go

Ⅰ. Describe what this PR does

This PR adds comments to the CachedState function in fluid/pkg/ddc/alluxio/operations/cached.go. The comments include a function doc comment describing the purpose, execution flow, and return values, as well as numbered inline comments explaining each logical step within the function body.

Ⅱ. Does this pull request fix one issue?

fixes #5940

Ⅲ.Special notes for reviews

The comment style follows the convention, with a structured doc comment (description + Returns section) and numbered inline comments (e.g., // 1. ..., // 2. ...) for each step in the function.

@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented Jun 2, 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 trafalgarzzz for approval by writing /assign @trafalgarzzz 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 Jun 2, 2026

Hi @YifeiZhang0508. 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.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 2, 2026

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 documentation and step-by-step comments to the CachedState function in pkg/ddc/alluxio/operations/cached.go to clarify how the Alluxio cluster's cached capacity is retrieved and parsed. Feedback on these changes suggests improving the robustness of the parsing logic by replacing a redundant len(values) == 0 check with a check for len(values) < 3 to ensure that a capacity value is actually present before attempting to parse it.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 57 to 59
values := strings.Fields(s)
if len(values) == 0 {
return cached, fmt.Errorf("failed to parse %s", s)
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

The check len(values) == 0 is redundant and acts as dead code because the preceding strings.Contains(s, "Used Capacity:") check guarantees that the string s contains non-whitespace characters, meaning strings.Fields(s) will always return at least 2 elements.

To make this check robust and prevent potential out-of-bounds or parsing issues (e.g., if the line is exactly "Used Capacity:" without a value, which would result in values[len(values)-1] being "Capacity:"), we should verify that len(values) is at least 3. This ensures that there is actually a capacity value field to parse.

if len(values) < 3 {
				return cached, fmt.Errorf("failed to parse %s", s)
			}

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented Jun 2, 2026

Hi @YifeiZhang0508, the DCO check has failed on this PR. Please ensure each commit has a Signed-off-by: Your Name <your@email> line. You can fix this by amending your commits with git commit --amend --signoff and force-pushing. Thanks!

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented Jun 3, 2026

/ok-to-test

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.36%. Comparing base (488376b) to head (0f9db50).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5941   +/-   ##
=======================================
  Coverage   63.35%   63.36%           
=======================================
  Files         481      481           
  Lines       33070    33072    +2     
=======================================
+ Hits        20953    20955    +2     
  Misses      10442    10442           
  Partials     1675     1675           

☔ 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.

Copy link
Copy Markdown
Collaborator

@cheyang cheyang left a comment

Choose a reason for hiding this comment

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

Thanks for adding documentation to the CachedState function, @YifeiZhang0508!

What looks good:

  • The function-level doc comment is well-structured and follows Go conventions (describes behavior, documents return values). This is genuinely useful for GoDoc.

Suggestions:

  1. DCO check is failing -- your commits need a Signed-off-by line. Please amend your commit(s) with git commit --amend -s (or git rebase --signoff if multiple commits) and force-push.

  2. Consider removing the numbered inline comments (// 1., // 2., // 3., // 4.) -- the function body is short (~20 lines) and the code is self-explanatory. In Go, inline comments that simply restate what the code does tend to add noise rather than clarity. The function doc comment you added already explains the overall logic well. If you want to keep inline comments, drop the numbering and only annotate the non-obvious parts (e.g., the unit conversion step).

  3. Minor nit: in the doc comment, "for returning" reads slightly awkward. Consider: "...converts the value to bytes." (dropping "for returning").

Blocking: DCO sign-off is required before this can merge.

/cc @fluid-cloudnative/maintainers

@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented Jun 3, 2026

@cheyang: GitHub didn't allow me to request PR reviews from the following users: fluid-cloudnative/maintainers.

Note that only fluid-cloudnative members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

Thanks for adding documentation to the CachedState function, @YifeiZhang0508!

What looks good:

  • The function-level doc comment is well-structured and follows Go conventions (describes behavior, documents return values). This is genuinely useful for GoDoc.

Suggestions:

  1. DCO check is failing -- your commits need a Signed-off-by line. Please amend your commit(s) with git commit --amend -s (or git rebase --signoff if multiple commits) and force-push.

  2. Consider removing the numbered inline comments (// 1., // 2., // 3., // 4.) -- the function body is short (~20 lines) and the code is self-explanatory. In Go, inline comments that simply restate what the code does tend to add noise rather than clarity. The function doc comment you added already explains the overall logic well. If you want to keep inline comments, drop the numbering and only annotate the non-obvious parts (e.g., the unit conversion step).

  3. Minor nit: in the doc comment, "for returning" reads slightly awkward. Consider: "...converts the value to bytes." (dropping "for returning").

Blocking: DCO sign-off is required before this can merge.

/cc @fluid-cloudnative/maintainers

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.

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented Jun 3, 2026

DCO check has failed. Please ensure your commits are signed off with git commit -s. See https://probot.github.io/apps/dco/ for details.\n

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 CachedState in fluid/pkg/ddc/alluxio/operations/cached.go

2 participants