From e39206e084ba259b7adf0cb32a4f0ee2eb8833fd Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Fri, 20 Nov 2015 13:49:40 -0800 Subject: [PATCH] etcdctl: cluster health exit with non-zero when cluster is unhealthy --- etcdctl/command/cluster_health.go | 7 ++++++- etcdctl/command/error.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) 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) {