Skip to content

Add GenerateShardRanges to vtctl commands#6752

Merged
deepthi merged 5 commits intovitessio:masterfrom
tinyspeck:am_list_shard_ranges
Sep 23, 2020
Merged

Add GenerateShardRanges to vtctl commands#6752
deepthi merged 5 commits intovitessio:masterfrom
tinyspeck:am_list_shard_ranges

Conversation

@ajm188
Copy link
Copy Markdown
Contributor

@ajm188 ajm188 commented Sep 20, 2020

Resolves #6751

Andrew Mason added 2 commits September 19, 2020 20:10
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
@ajm188 ajm188 requested a review from sougou as a code owner September 20, 2020 00:53
@ajm188 ajm188 requested a review from rafael September 20, 2020 00:58
Copy link
Copy Markdown
Member

@rafael rafael left a comment

Choose a reason for hiding this comment

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

From my perspective this is a great idea to have a first class citizen. I've seen this come up multiple times in Slack where people it's not super sure about how to generate the shard ranges for a shard.

After thinking a bit more about this, we could also add this script to the contrib one. Personally, I think it makes more sense here.

@deepthi what do you think about this?

{"ListTablets", commandListTablets,
"<tablet alias> ...",
"Lists specified tablets in an awk-friendly way."},
{"ListShardRanges", commandListShardRanges,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit - Maybe "GenerateShardRanges" ? I think List reads as something that already exists.

@deepthi
Copy link
Copy Markdown
Collaborator

deepthi commented Sep 21, 2020

From my perspective this is a great idea to have a first class citizen. I've seen this come up multiple times in Slack where people it's not super sure about how to generate the shard ranges for a shard.

After thinking a bit more about this, we could also add this script to the contrib one. Personally, I think it makes more sense here.

@deepthi what do you think about this?

I think it's a great idea :) +1 on keeping it in the main repo and not in contrib.

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := listShardRanges(tt.args.shards)
if (err != nil) != tt.wantErr {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

May I suggest replacing the more verbose comparisons with assert and require?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Absolutely!

Andrew Mason added 2 commits September 21, 2020 16:07
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
@ajm188 ajm188 changed the title Add ListShardRanges to vtctl commands Add GenerateShardRanges to vtctl commands Sep 21, 2020
func TestShardCalculatorForShardsGreaterThan512(t *testing.T) {
got, err := generateShardRanges(512)
if err != nil {
t.Errorf("listShardRanges() error = %v", err)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

missed a few

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🙈 oops! fixed

Signed-off-by: Andrew Mason <amason@slack-corp.com>
Copy link
Copy Markdown
Collaborator

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

LGTM

start := 0
end := 0

// If shards does not divide evenly into maxShards, then there is some lossiness,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice implementation and documentation 👍

@deepthi deepthi merged commit 27fd491 into vitessio:master Sep 23, 2020
@askdba askdba added this to the v8.0 milestone Oct 6, 2020
@ajm188 ajm188 deleted the am_list_shard_ranges branch January 14, 2021 15:41
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.

Expose a shard range calculator as a vtctl command

4 participants