mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3442 from xiang90/b
etcdctl: prepare for health endpoint change
This commit is contained in:
commit
39580479b5
@ -3,6 +3,7 @@ package command
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@ -70,9 +71,18 @@ func handleClusterHealth(c *cli.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result := struct{ Health string }{}
|
result := struct{ Health string }{}
|
||||||
d := json.NewDecoder(resp.Body)
|
nresult := struct{ Health bool }{}
|
||||||
err = d.Decode(&result)
|
bytes, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("failed to check the health of member %s on %s: %v\n", m.ID, url, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
|
||||||
|
err = json.Unmarshal(bytes, &result)
|
||||||
|
if err != nil {
|
||||||
|
err = json.Unmarshal(bytes, &nresult)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("failed to check the health of member %s on %s: %v\n", m.ID, url, err)
|
fmt.Printf("failed to check the health of member %s on %s: %v\n", m.ID, url, err)
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user