Skip to content

Add comments to AllocateBatch in pkg/ddc/base/portallocator/bitmap_allocator.go#5800

Open
caterpillar-1 wants to merge 2 commits intofluid-cloudnative:masterfrom
caterpillar-1:docs/comments_bitmap_allocator_AllocateBatch
Open

Add comments to AllocateBatch in pkg/ddc/base/portallocator/bitmap_allocator.go#5800
caterpillar-1 wants to merge 2 commits intofluid-cloudnative:masterfrom
caterpillar-1:docs/comments_bitmap_allocator_AllocateBatch

Conversation

@caterpillar-1
Copy link
Copy Markdown

Ⅰ. Describe what this PR does

Add comments to AllocateBatch in pkg/ddc/base/portallocator/bitmap_allocator.go

Ⅱ. Does this pull request fix one issue?

fixes #5799

III. Special notes for reviews

…locator.go

Signed-off-by: Caterpillar <w@caterpillar.ink>
@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented Apr 22, 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 Apr 22, 2026

Hi @caterpillar-1. 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 for the AllocateBatch method in the BitMapAllocator. The review feedback identifies inaccuracies in the documentation, specifically regarding the claim that ports are allocated consecutively and the description of the error return value, as the function terminates the process on failure rather than returning an error.

}

// AllocateBatch allocates a batch of ports from the bitmap allocator.
// This function attempts to allocate the specified number of consecutive ports and returns them as a slice.
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 comment states that the function attempts to allocate "consecutive" ports. However, the implementation calls AllocateNext() in a loop, which retrieves available ports from the bitmap but does not guarantee they are contiguous.

Suggested change
// This function attempts to allocate the specified number of consecutive ports and returns them as a slice.
// This function attempts to allocate the specified number of ports and returns them as a slice.

//
// Returns:
// - ports ([]int): A slice containing the allocated port numbers
// - err (error): Error if allocation fails (note: function exits process on failure)
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 documentation for the err return value is misleading. Since the function terminates the process on failure (as noted in the implementation and the function description), it never actually returns a non-nil error to the caller. If the function returns, err will always be nil.

Suggested change
// - err (error): Error if allocation fails (note: function exits process on failure)
// - err (error): Always nil if the function returns (note: function exits process on failure)

Signed-off-by: Caterpillar <w@caterpillar.ink>
@caterpillar-1 caterpillar-1 force-pushed the docs/comments_bitmap_allocator_AllocateBatch branch from 48a409f to 4c6d463 Compare April 22, 2026 20:19
@sonarqubecloud
Copy link
Copy Markdown

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/bitmap_allocator.go

1 participant