Skip to content
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 a no-ttl flag to etcdctl migrate to discard keys on transform. #6793

Merged
merged 1 commit into from
Nov 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions etcdctl/ctlv3/command/migrate_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ import (
)

var (
migrateDatadir string
migrateWALdir string
migrateTransformer string
migrateExcludeTTLKey bool
migrateDatadir string
migrateWALdir string
migrateTransformer string
)

// NewMigrateCommand returns the cobra command for "migrate".
Expand All @@ -55,6 +56,7 @@ func NewMigrateCommand() *cobra.Command {
Run: migrateCommandFunc,
}

mc.Flags().BoolVar(&migrateExcludeTTLKey, "no-ttl", false, "Do not convert TTL keys")
mc.Flags().StringVar(&migrateDatadir, "data-dir", "", "Path to the data directory")
mc.Flags().StringVar(&migrateWALdir, "wal-dir", "", "Path to the WAL directory")
mc.Flags().StringVar(&migrateTransformer, "transformer", "", "Path to the user-provided transformer program")
Expand Down Expand Up @@ -216,11 +218,13 @@ func writeKeys(w io.Writer, n *store.NodeExtern) uint64 {
if n.Dir {
n.Nodes = nil
}
b, err := json.Marshal(n)
if err != nil {
ExitWithError(ExitError, err)
if !migrateExcludeTTLKey || n.TTL == 0 {
b, err := json.Marshal(n)
if err != nil {
ExitWithError(ExitError, err)
}
fmt.Fprint(w, string(b))
}
fmt.Fprint(w, string(b))
for _, nn := range nodes {
max := writeKeys(w, nn)
if max > maxIndex {
Expand Down