Merge pull request #4455 from heyitsanthony/etcdctlv3-compaction-err

etcdctlv3: report compaction error, if any
This commit is contained in:
Anthony Romano 2016-02-08 19:15:40 -08:00
commit 15c8876e4c
2 changed files with 9 additions and 6 deletions

View File

@ -124,7 +124,7 @@ func (kv *kv) Compact(rev int64) error {
}
go kv.switchRemote(err)
return nil
return err
}
func (kv *kv) Txn() Txn {

View File

@ -19,14 +19,13 @@ import (
"strconv"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/spf13/cobra"
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
"github.com/coreos/etcd/clientv3"
)
// NewCompactionCommand returns the cobra command for "compaction".
func NewCompactionCommand() *cobra.Command {
return &cobra.Command{
Use: "compaction",
Use: "compaction <revision>",
Short: "Compaction compacts the event history in etcd.",
Run: compactionCommandFunc,
}
@ -43,6 +42,10 @@ func compactionCommandFunc(cmd *cobra.Command, args []string) {
ExitWithError(ExitError, err)
}
req := &pb.CompactionRequest{Revision: rev}
mustClient(cmd).KV.Compact(context.Background(), req)
c := mustClient(cmd)
if cerr := clientv3.NewKV(c).Compact(rev); cerr != nil {
ExitWithError(ExitError, cerr)
return
}
fmt.Println("compacted revision", rev)
}