Repository navigation
fix(pool): set_pool crashed on an omitted size argument - #1295
Merged
Merged
Conversation
`sbctl pool set <id> --pool-max 4TB` failed with
Operation failed: '>' not supported between instances of 'NoneType' and 'int'
The `set` subcommand declares no argparse default for --pool-max/--lvol-max
(unlike `add`, which defaults both to '0'), so argparse supplies None for
whichever the user omits. clibase.storage_pool__set forwards
args.pool_max/args.lvol_max positionally and unconditionally, so that None
reached set_pool and overrode its own `=0` default. None then fell through
the `== 0` guard (None != 0) straight into `> 0` and raised. The reported
command actually died on the omitted --lvol-max, not on --pool-max; passing
--lvol-max alone hits the same crash in the pool_max branch.
Fix by treating None as "not specified, leave unchanged" rather than
coercing it to 0. Coercion would have been wrong: 0 is a meaningful value
here -- it resets the limit to unlimited -- so `pool_max = pool_max or 0`
would turn every partial update into a silent reset of the size the caller
did not mention. That also fixes the same latent bug on the v1 API path,
which only forwards the keys present in the request body.
Note add_pool already normalises both sizes (`pool_max = pool_max or 0`);
set_pool simply never got the equivalent treatment.
Also fixes a field mix-up in the same block: the `lvol_max > 0` branch
assigned to `pool.pool_max_size` instead of `pool.lvol_max_size`, so a
non-zero --lvol-max silently overwrote the pool-wide limit and never set the
per-lvol limit at all. The `== 0` branch three lines above already used the
correct field, which is what makes the mismatch visible.
Tests cover the cases nothing exercised before: each size omitted, both
omitted, explicit zero still resetting, negatives still rejected, and
lvol_max writing its own field without clobbering pool_max_size. They fail
9/10 against the previous code (including the exact reported TypeError) and
pass with this change.
schmidt-scaled
pushed a commit
that referenced
this pull request
Sep 3, 2026
`sbctl pool set <id> --pool-max 4TB` failed with
Operation failed: '>' not supported between instances of 'NoneType' and 'int'
The `set` subcommand declares no argparse default for --pool-max/--lvol-max
(unlike `add`, which defaults both to '0'), so argparse supplies None for
whichever the user omits. clibase.storage_pool__set forwards
args.pool_max/args.lvol_max positionally and unconditionally, so that None
reached set_pool and overrode its own `=0` default. None then fell through
the `== 0` guard (None != 0) straight into `> 0` and raised.
Fix by treating None as "not specified, leave unchanged" rather than 0,
because 0 is a meaningful value here: it resets the limit to unlimited.
Also fixes the field mix-up in the lvol_max branch, which assigned the
per-lvol limit to pool_max_size instead of lvol_max_size — a non-zero
--lvol-max silently overwrote the whole-pool limit and never set
lvol_max_size at all.
(cherry picked from R26.2-PRE commit cb0d406; adapted for main: test
placed in tests/unit/, ops_gate mock created with unsafe=True since the
gate method name starts with 'assert')
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
schmidt-scaled
pushed a commit
that referenced
this pull request
Sep 3, 2026
`sbctl pool set <id> --pool-max 4TB` failed with
Operation failed: '>' not supported between instances of 'NoneType' and 'int'
The `set` subcommand declares no argparse default for --pool-max/--lvol-max
(unlike `add`, which defaults both to '0'), so argparse supplies None for
whichever the user omits. clibase.storage_pool__set forwards
args.pool_max/args.lvol_max positionally and unconditionally, so that None
reached set_pool and overrode its own `=0` default. None then fell through
the `== 0` guard (None != 0) straight into `> 0` and raised.
Fix by treating None as "not specified, leave unchanged" rather than 0,
because 0 is a meaningful value here: it resets the limit to unlimited.
Also fixes the field mix-up in the lvol_max branch, which assigned the
per-lvol limit to pool_max_size instead of lvol_max_size — a non-zero
--lvol-max silently overwrote the whole-pool limit and never set
lvol_max_size at all.
(cherry picked from R26.2-PRE commit cb0d406; adapted for R26.3: test
placed in tests/unit/, ops_gate mock created with unsafe=True since the
gate method name starts with 'assert')
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sbctl pool set <id> --pool-max 4TBfailed withThe
setsubcommand declares no argparse default for --pool-max/--lvol-max (unlikeadd, which defaults both to '0'), so argparse supplies None for whichever the user omits. clibase.storage_pool__set forwards args.pool_max/args.lvol_max positionally and unconditionally, so that None reached set_pool and overrode its own=0default. None then fell through the== 0guard (None != 0) straight into> 0and raised. The reported command actually died on the omitted --lvol-max, not on --pool-max; passing --lvol-max alone hits the same crash in the pool_max branch.Fix by treating None as "not specified, leave unchanged" rather than coercing it to 0. Coercion would have been wrong: 0 is a meaningful value here -- it resets the limit to unlimited -- so
pool_max = pool_max or 0would turn every partial update into a silent reset of the size the caller did not mention. That also fixes the same latent bug on the v1 API path, which only forwards the keys present in the request body.Note add_pool already normalises both sizes (
pool_max = pool_max or 0); set_pool simply never got the equivalent treatment.Also fixes a field mix-up in the same block: the
lvol_max > 0branch assigned topool.pool_max_sizeinstead ofpool.lvol_max_size, so a non-zero --lvol-max silently overwrote the pool-wide limit and never set the per-lvol limit at all. The== 0branch three lines above already used the correct field, which is what makes the mismatch visible.Tests cover the cases nothing exercised before: each size omitted, both omitted, explicit zero still resetting, negatives still rejected, and lvol_max writing its own field without clobbering pool_max_size. They fail 9/10 against the previous code (including the exact reported TypeError) and pass with this change.