Browse Source

Merge pull request #3905 from xiang90/etcdctl_health

etcdctl: cluster health exit with non-zero when cluster is unhealthy
Xiang Li 10 years ago
parent
commit
31574cb9da
2 changed files with 7 additions and 1 deletions
  1. 6 1
      etcdctl/command/cluster_health.go
  2. 1 0
      etcdctl/command/error.go

+ 6 - 1
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)
 	}

+ 1 - 0
etcdctl/command/error.go

@@ -27,6 +27,7 @@ const (
 	ExitBadConnection
 	ExitBadAuth
 	ExitServerError
+	ExitClusterNotHealthy
 )
 
 func handleError(code int, err error) {