settings: surface validation bounds for numeric cluster settings#172040
settings: surface validation bounds for numeric cluster settings#172040lohitkolluri wants to merge 2 commits into
Conversation
|
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. Before a member of our team reviews your PR, I have some potential action items for you:
I have added a few people who may be able to assist in reviewing:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Cluster-setting validation bounds (min/max) were captured only inside opaque validateFn closures, so callers of gen settings-list, SHOW CLUSTER SETTING, crdb_internal.cluster_settings, and the admin HTTP API had no way to discover them without trial-and-error. For example, sql.status.active_query_text.max_bytes accepts values in [1000 B, 64 KiB] but this is not surfaced anywhere. This change records the bounds on the concrete numeric setting types (IntSetting, ByteSizeSetting, FloatSetting, DurationSetting) so they can be surfaced for documentation and introspection. A new optional 'boundsOpt' field on SettingOption is invoked after the setting is registered, populated by the existing validation constructors (IntInRange, IntWithMinimum, IntInRangeOrZeroDisable, ByteSize*, DurationInRange, DurationWithMinimum, DurationWithMinimumOrZeroDisable, FloatInRange, FloatInRangeUpperExclusive, FloatWithMinimum, FloatWithMinimumOrZeroDisable, and the derived Fraction / NonNegative* options). Bounds are exposed via a typed Bounds() method on each numeric setting; nil pointer means the corresponding bound is unbounded. The upper-exclusive semantics of FloatInRangeUpperExclusive is intentionally not surfaced (inclusive range only) and is left for a follow-up. Validation behavior, error messages, and existing call sites are unchanged. No interface changes; the change is purely additive. Release note (general change): Expose validation bounds (min/max) of numeric cluster settings via a new Bounds() method on IntSetting/ByteSizeSetting/FloatSetting/DurationSetting so callers can surface them in docs, SHOW CLUSTER SETTING, and HTTP APIs. Release-Note: general change Signed-off-by: Lohit Kolluri <lohitkolluri@gmail.com>
The validation bounds recorded by the new Bounds() accessors in pkg/settings are now visible to users. Two new columns, Min and Max, are appended to the table emitted by `cockroach gen settings-list` and the corresponding docs/generated/settings/settings.html genrule is regenerated. Each numeric setting now displays its bounds in the canonical form a user would supply to SET CLUSTER SETTING (e.g. 10, 0.5, 1h0m0s); non-numeric settings and unbounded sides render as empty cells. `gen settings-list --without-system-only` (settings-for-tenants.txt) is also regenerated. Release note (general change): `cockroach gen settings-list` (and the regenerated docs/generated/settings/settings.html and settings-for-tenants.txt) now include Min and Max columns showing the validation bounds of numeric cluster settings. Release-Note: general change Signed-off-by: Lohit Kolluri <lohitkolluri@gmail.com>
b5c0e58 to
1c3acc2
Compare
|
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. Thank you for updating your pull request. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
|
Heads-up: this PR covers items 1 and 2 from the issue's expected behavior:
Item 3 ( I'm happy to open a separate PR for that if you'd prefer, or leave it for whoever picks it up next. |
|
Thanks for the contribution @lohitkolluri! I've requested a review from the owning team for cluster settings infra.
Separate PR sounds good, but in that case please change "Fixes #172035" to say "Informs" so the issue doesn't get auto-closed. |
Summary
Cluster settings now expose their validation bounds. The valid range for settings like
kv.snapshot_rebalance.max_ratewas hidden inside the validator, so users had to discover it by trial and error or by reading error messages. This change records the min and max on each setting and shows them in the generated settings list.Informs #172035.
What changed
Two commits.
Record bounds on each setting. The four numeric setting types (int, byte size, float, duration) now store their min and max values, exposed via a new
Bounds()method.Show bounds in the settings list.
cockroach gen settings-list(and the generated docs it produces) now includesMinandMaxcolumns showing the valid range for each numeric setting.Out of scope
SHOW CLUSTER SETTING, the internal settings table, and the admin HTTP API. The data is now available; making it visible there is a follow-up.Testing
sql.trace.txn.sample_rateshows Min=0, Max=1;kv.snapshot_rebalance.max_rateshows Min=1048576, no max).AI disclosure: Drafted with assistance from Claude Code.
Epic: CRDB-37791