-
Notifications
You must be signed in to change notification settings - Fork 420
Add --all and --repo flags to kv dump command #9874
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
base: master
Are you sure you want to change the base?
Conversation
- Add --all flag to dump all known partitions - Add --repo flag to dump specific repository partition - Add unit tests for dump functionality Closes treeverse#9857
arielshaqed
left a comment
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.
Thanks! Let's test it, and we'll go over now tests later.
cmd/lakefs/cmd/kv.go
Outdated
| kv - kv internal metadata | ||
| Default: all supported sections (auth, pulls, kv)`, | ||
| Default: all supported sections (auth, pulls, kv) |
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.
Let's now avoid the word "all" here, given that it's but the same as the flag.
cmd/lakefs/cmd/kv.go
Outdated
| var dump *kv.DumpFormat | ||
|
|
||
| // Handle different dump modes | ||
| if allFlag { |
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.
This would be easier for me to read as a switch statement.
cmd/lakefs/cmd/kv.go
Outdated
| var repoData graveler.RepositoryData | ||
| _, err := kv.GetMsg(ctx, kvStore, graveler.RepositoriesPartition(), []byte(repoPath), &repoData) | ||
| if err != nil { | ||
| if errors.Is(err, kv.ErrNotFound) { |
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.
Use just errors.Is , which is false for nil. This style is used throughout lakeFS.
|
|
||
| func TestCreateDumpWithPartitions(t *testing.T) { | ||
| ctx := t.Context() | ||
| store := kvtest.GetStore(ctx, t) |
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.
Surprised this works tbh, cool!
| dump, err := kv.CreateDumpWithPartitions(ctx, store, []string{"partition1", "partition2"}) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, dump) | ||
| require.Len(t, dump.Entries, 3) |
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.
Can you verify the returned values?
- Fix duplicate graveler import - Use static error variables for linter compliance - Refactor if/else to switch statement - Simplify error handling with errors.Is pattern - Add value verification in dump tests
|
Hi @arielshaqed, thanks for taking the time to review! I've pushed a new commit addressing your feedback:
Let me know if there's anything else I should change! |
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.
Thanks! I'll get CI to pass (but please go over my comments) and then pull.
pkg/kv/dump.go
Outdated
| "kv": {"kv-internal-metadata"}, // kv internal metadata | ||
| } | ||
|
|
||
| // GetAllKnownPartitions returns all partitions defined in SectionMapping |
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.
Why do we need this? CreateDump still tests len(partitions) == 0 and collects all known partitions.
pkg/kv/dump_test.go
Outdated
| require.Equal(t, len(expectedPartitions), len(partitions), "should return all unique partitions") | ||
|
|
||
| for _, partition := range partitions { | ||
| require.True(t, expectedPartitions[partition], "partition %s should be in expected list", partition) | ||
| } | ||
| } |
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.
- Use CreateDump with empty sections for --all flag - Remove redundant GetAllKnownPartitions function and test - Fix gofmt formatting
|
Hi @arielshaqed, I've addressed your comments:
Thanks again for the helpful feedback! |
|
One last question - have you run it to see that it works (beyond unit tests, which are all well and good but...)? |
|
Yes! I've tested it locally using quickstart mode:
All flags work as expected. The dump is empty since quickstart has no data, |
Summary
This PR adds two new flags to the
lakefs kv dumpcommand as requested in #9857:--all: Dumps all known partitions instead of just the predefined sections--repo <name>: Dumps only the partition for a specific repositoryChanges
--allflag to enumerate and dump all partitions from SectionMapping--repoflag to dump a specific repository's partition using gravelerGetAllKnownPartitions()andCreateDumpWithPartitions()helper functionsUsage
Test
Closes #9857