Skip to content

fix(pool): set_pool crashed on an omitted size argument - #1295

Merged
wmousa merged 1 commit into
R26.2-PREfrom
fix/pool-set-none-size-args
Sep 2, 2026
Merged

wmousa merged 1 commit into
R26.2-PREfrom
fix/pool-set-none-size-args

Conversation

@wmousa

@wmousa wmousa commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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.

`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.
@wmousa
wmousa merged commit cb0d406 into R26.2-PRE Sep 2, 2026
4 of 7 checks passed
@wmousa
wmousa deleted the fix/pool-set-none-size-args branch September 2, 2026 11:23
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant