mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #5065 from heyitsanthony/errexit-defrag
etcdctl: return non-zero exit code if defrag fails on any endpoint
This commit is contained in:
commit
993f25f055
@ -31,6 +31,7 @@ func NewDefragCommand() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func defragCommandFunc(cmd *cobra.Command, args []string) {
|
func defragCommandFunc(cmd *cobra.Command, args []string) {
|
||||||
|
failures := 0
|
||||||
c := mustClientFromCmd(cmd)
|
c := mustClientFromCmd(cmd)
|
||||||
for _, ep := range c.Endpoints() {
|
for _, ep := range c.Endpoints() {
|
||||||
ctx, cancel := commandCtx(cmd)
|
ctx, cancel := commandCtx(cmd)
|
||||||
@ -38,8 +39,13 @@ func defragCommandFunc(cmd *cobra.Command, args []string) {
|
|||||||
cancel()
|
cancel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Failed to defragment etcd member[%s] (%v)\n", ep, err)
|
fmt.Fprintf(os.Stderr, "Failed to defragment etcd member[%s] (%v)\n", ep, err)
|
||||||
|
failures++
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Finished defragmenting etcd member[%s]\n", ep)
|
fmt.Printf("Finished defragmenting etcd member[%s]\n", ep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if failures != 0 {
|
||||||
|
os.Exit(ExitError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user