-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GenerateShardRanges to vtctl commands #6752
Conversation
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
There was a problem hiding this 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?
go/vt/vtctl/vtctl.go
Outdated
@@ -378,6 +378,9 @@ var commands = []commandGroup{ | |||
{"ListTablets", commandListTablets, | |||
"<tablet alias> ...", | |||
"Lists specified tablets in an awk-friendly way."}, | |||
{"ListShardRanges", commandListShardRanges, |
There was a problem hiding this comment.
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.
I think it's a great idea :) +1 on keeping it in the main repo and not in contrib. |
go/vt/vtctl/vtctl_test.go
Outdated
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := listShardRanges(tt.args.shards) | ||
if (err != nil) != tt.wantErr { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely!
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
go/vt/vtctl/vtctl_test.go
Outdated
func TestShardCalculatorForShardsGreaterThan512(t *testing.T) { | ||
got, err := generateShardRanges(512) | ||
if err != nil { | ||
t.Errorf("listShardRanges() error = %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed a few
There was a problem hiding this comment.
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>
There was a problem hiding this 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice implementation and documentation 👍
Resolves #6751