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