Skip to content

This PR is to add comments to AllocateBatch in pkg/ddc/base/portallocator/random_allocator.go.#5917

Open
sleepyhead55 wants to merge 1 commit into
fluid-cloudnative:masterfrom
sleepyhead55:add-comment-allocatebatch
Open

This PR is to add comments to AllocateBatch in pkg/ddc/base/portallocator/random_allocator.go.#5917
sleepyhead55 wants to merge 1 commit into
fluid-cloudnative:masterfrom
sleepyhead55:add-comment-allocatebatch

Conversation

@sleepyhead55
Copy link
Copy Markdown

…locator.go.

Ⅰ. Describe what this PR does

Add detailed comments for function AllocateBatch in random_allocator.go.

Ⅱ. Does this pull request fix one issue?

fixes #5916

Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

None

…locator.go.

Signed-off-by: sleepyhead55 <3047991541@qq.com>
@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented May 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 May 26, 2026

Hi @sleepyhead55. 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 documentation comments to the AllocateBatch method in random_allocator.go. The reviewer pointed out a contradiction in the comments regarding whether the method modifies shared state requiring a lock or only uses a local map. The documentation should be clarified to accurately describe what the lock protects.

Comment on lines +75 to +76
// This method is concurrency-safe as it acquires a lock before modifying the port allocation state.
// Note: The allocated ports are not persisted; they are only stored in the local map to avoid duplicates within the same batch.
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

There is a contradiction between line 75 and line 76:

  • Line 75 states that the method "acquires a lock before modifying the port allocation state."
  • Line 76 states that "allocated ports are not persisted; they are only stored in the local map."

Since the allocatedPorts map is local to the function invocation, it does not require synchronization. If a lock is indeed acquired, it is likely protecting a shared random number generator (which is not thread-safe in Go if using a custom rand.Rand) rather than any "port allocation state".

Please clarify the comment to accurately reflect what the lock protects to avoid misleading future maintainers.

@sonarqubecloud
Copy link
Copy Markdown

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 26, 2026

/ok-to-test

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.59%. Comparing base (9e74e92) to head (a85b99f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5917   +/-   ##
=======================================
  Coverage   62.59%   62.59%           
=======================================
  Files         480      480           
  Lines       32801    32801           
=======================================
  Hits        20533    20533           
  Misses      10633    10633           
  Partials     1635     1635           

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

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 27, 2026

🔄 kind-e2e-test (v1.24.17) 失败,其余 4 个 e2e 版本全部通过。失败原因是 curvine cache runtime 测试不稳定,与 comment-only 改动无关。已重试该 job。

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 27, 2026

/lgtm /approve

🤖 Automated comment-only review — This PR adds documentation comments to AllocateBatch in pkg/ddc/base/portallocator/random_allocator.go. Comment-only change confirmed (high confidence), DCO passed, all required checks passed including e2e tests across 5 Kubernetes versions.

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 28, 2026

/lgtm /approve

This PR is comment-only (adds documentation comments to Go source). All required checks pass, DCO passes, no blocking labels. Auto-approved by comment-only review bot.

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 28, 2026

/lgtm /approve

Automated review for comment-only PR. Diff confirmed: only comments/documentation text changed. DCO ✓, all required checks ✓.

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 29, 2026

/lgtm /approve

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 AllocateBatch in pkg/ddc/base/portallocator/random_allocator.go.

2 participants