Skip to content

fix(sandboxclaim): make claim batch size flag actually take effect#656

Merged
furykerry merged 1 commit into
openkruise:masterfrom
Luckydog691:fix/sandboxclaim-batch-size-flag
Jul 17, 2026
Merged

fix(sandboxclaim): make claim batch size flag actually take effect#656
furykerry merged 1 commit into
openkruise:masterfrom
Luckydog691:fix/sandboxclaim-batch-size-flag

Conversation

@Luckydog691

Copy link
Copy Markdown
Contributor

Ⅰ. Describe what this PR does

The -sandboxclaim-max-batch-size flag has never had any effect. It was
bound to a package variable maxClaimBatchSize (default 10) that no code
reads, while the claim logic uses the core.MaxClaimBatchSize constant
(50). So setting the flag did nothing, and its advertised default (10) did
not even match the effective value (50).

This PR:

  • Wires -sandboxclaim-max-batch-size to core.MaxClaimBatchSize (turned
    into a var) so it actually takes effect.
  • Adds -sandboxclaim-initial-batch-size to also tune the initial ramp-up
    size (core.InitialClaimBatchSize).
  • Removes the now-unused maxClaimBatchSize variable.

No behavior change by default: the effective defaults stay 50 / 5. Only
the flag's advertised default is corrected (10 → 50).

6 insertions, 3 deletions across two files.

Ⅱ. Does this pull request fix one issue?

NONE. Found while trying to tune claim throughput and noticing the flag had
no effect.

Ⅲ. Describe how to verify it

  • Before: start the controller with -sandboxclaim-max-batch-size=100.
    The claim loop still batches at 50 (the constant) — the flag is ignored.
  • After: the same flag caps the batch at 100; -sandboxclaim-initial-batch-size
    likewise controls the ramp-up start.
  • Default unchanged: with no flags, batch size stays 50 and initial 5,
    identical to before.
go build ./pkg/controller/sandboxclaim/...
go test ./pkg/controller/sandboxclaim/...

Ⅳ. Special notes for reviews

  • constvar for the two batch sizes is required so they can be bound
    to flags via flag.IntVar.
  • Effective runtime defaults are unchanged (50 / 5). No deployment manifest
    in this repo passes the flag, so wiring it up cannot alter existing
    behavior; only explicit user-provided values now take effect.
  • The flag has been non-functional since it was introduced (PR feat: implement SandboxClaim CRD for sandbox resource claiming #114), so no
    existing user could have depended on it working.

The -sandboxclaim-max-batch-size flag was bound to a package variable
(maxClaimBatchSize, default 10) that no code ever read. The real claim
logic uses the core.MaxClaimBatchSize constant (50), so the flag was
dead: setting it had no effect, and its advertised default (10) did not
even match the effective value (50).

Bind the flag directly to core.MaxClaimBatchSize (turned into a var), and
add a matching -sandboxclaim-initial-batch-size flag for the exponential
ramp-up start value (core.InitialClaimBatchSize). This lets operators tune
claim throughput for large-scale deployments as intended, and removes the
now-unused maxClaimBatchSize variable.

Signed-off-by: liujiuyi <liujiuyi.ljy@alibaba-inc.com>
@kruise-bot

Copy link
Copy Markdown

[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 zmberg for approval by writing /assign @zmberg 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

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.06%. Comparing base (a486634) to head (17b8a6b).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #656      +/-   ##
==========================================
+ Coverage   80.04%   80.06%   +0.01%     
==========================================
  Files         229      229              
  Lines       17861    17863       +2     
==========================================
+ Hits        14297    14302       +5     
+ Misses       2978     2976       -2     
+ Partials      586      585       -1     
Flag Coverage Δ
unittests 80.06% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@furykerry
furykerry merged commit ef43b4b into openkruise:master Jul 17, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants