diff --git a/etcdctl/command/cluster_health.go b/etcdctl/command/cluster_health.go index 4f2d5f99d..0d6085f56 100644 --- a/etcdctl/command/cluster_health.go +++ b/etcdctl/command/cluster_health.go @@ -122,8 +122,13 @@ func handleClusterHealth(c *cli.Context) { } if !forever { - break + if health { + os.Exit(ExitSuccess) + } else { + os.Exit(ExitClusterNotHealthy) + } } + fmt.Printf("\nnext check after 10 second...\n\n") time.Sleep(10 * time.Second) } diff --git a/etcdctl/command/error.go b/etcdctl/command/error.go index a521da739..83a80b26e 100644 --- a/etcdctl/command/error.go +++ b/etcdctl/command/error.go @@ -27,6 +27,7 @@ const ( ExitBadConnection ExitBadAuth ExitServerError + ExitClusterNotHealthy ) func handleError(code int, err error) {