|
@@ -35,6 +35,7 @@ func NewDefragCommand() *cobra.Command {
|
|
|
Short: "Defragments the storage of the etcd members with given endpoints",
|
|
Short: "Defragments the storage of the etcd members with given endpoints",
|
|
|
Run: defragCommandFunc,
|
|
Run: defragCommandFunc,
|
|
|
}
|
|
}
|
|
|
|
|
+ cmd.PersistentFlags().BoolVar(&epClusterEndpoints, "cluster", false, "use all endpoints from the cluster member list")
|
|
|
cmd.Flags().StringVar(&defragDataDir, "data-dir", "", "Optional. If present, defragments a data directory not in use by etcd.")
|
|
cmd.Flags().StringVar(&defragDataDir, "data-dir", "", "Optional. If present, defragments a data directory not in use by etcd.")
|
|
|
return cmd
|
|
return cmd
|
|
|
}
|
|
}
|
|
@@ -51,7 +52,7 @@ func defragCommandFunc(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
|
|
failures := 0
|
|
failures := 0
|
|
|
c := mustClientFromCmd(cmd)
|
|
c := mustClientFromCmd(cmd)
|
|
|
- for _, ep := range c.Endpoints() {
|
|
|
|
|
|
|
+ for _, ep := range endpointsFromCluster(cmd) {
|
|
|
ctx, cancel := commandCtx(cmd)
|
|
ctx, cancel := commandCtx(cmd)
|
|
|
_, err := c.Defragment(ctx, ep)
|
|
_, err := c.Defragment(ctx, ep)
|
|
|
cancel()
|
|
cancel()
|