Skip to content

allow specifying the hex width to use when generating shard ranges#723

Merged
frouioui merged 5 commits intomainfrom
florent-hex-width-shard-range
Sep 25, 2025
Merged

allow specifying the hex width to use when generating shard ranges#723
frouioui merged 5 commits intomainfrom
florent-hex-width-shard-range

Conversation

@frouioui
Copy link
Member

This ports vitessio/vitess#18633 to the vitess-operator.

This PR adds the field hexWidth in the CRD, in VitessKeyspaceEqualPartitioning. With it, users can specify the width of their shard names. The default value is set by the kubebuilder to 0, which makes it a no-op and backward compatible for previous versions of Vitess or for people not using hex width.

@frouioui frouioui changed the title bump go version to go1.25.1 allow specifying the hex width to use when generating shard ranges Sep 24, 2025
Copy link
Contributor

@nickvanw nickvanw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending one question about data validation

hexWidth:
default: 0
format: int32
maximum: 65536
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reasonable maximum for this that isn't int32 max?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have based it on the maximum size we support in vitess:

	default:
		return nil, errors.New("this function does not support more than 65536 shards in a single keyspace")

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
@frouioui frouioui force-pushed the florent-hex-width-shard-range branch from 260c243 to 1698c81 Compare September 25, 2025 15:38
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
// +kubebuilder:default=0
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65536
HexWidth int32 `json:"hexWidth"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required? If not we should add an omitempty tag

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. Adding the tag via 61201eb.

I think the kubebuilder default was preventing this to error given a default is always set, but with the omitempty tag the CRD/api looks cleaner

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
@frouioui frouioui merged commit 6282e16 into main Sep 25, 2025
12 checks passed
@frouioui frouioui deleted the florent-hex-width-shard-range branch September 25, 2025 16:37
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.

4 participants