Added end maintenance API which allows DRAINED hosts to be transitioned to ACTIVE. Fixed bug where payload error would never be returned if call failed due to a bad payload.

This commit is contained in:
Renan DelValle 2017-09-27 12:55:50 -07:00
parent f59f0bbdc3
commit 8fe3780949
2 changed files with 91 additions and 6 deletions

View file

@ -28,7 +28,7 @@ import (
"strings"
)
var cmd, executor, url, clustersConfig, clusterName, updateId, username, password, zkUrl, drainCandidates string
var cmd, executor, url, clustersConfig, clusterName, updateId, username, password, zkUrl, hostList string
var CONNECTION_TIMEOUT = 20000
@ -42,7 +42,7 @@ func init() {
flag.StringVar(&username, "username", "aurora", "Username to use for authorization")
flag.StringVar(&password, "password", "secret", "Password to use for authorization")
flag.StringVar(&zkUrl, "zkurl", "", "zookeeper url")
flag.StringVar(&drainCandidates, "drainCandidates", "", "Comma separated list of candidate hosts to drain")
flag.StringVar(&hostList, "hostList", "", "Comma separated list of hosts to operate on")
flag.Parse()
}
@ -501,11 +501,11 @@ func main() {
case "drainHosts":
fmt.Println("Setting hosts to DRAINING")
if drainCandidates == "" {
if hostList == "" {
fmt.Println("No hosts specified to drain")
os.Exit(1)
}
hosts := strings.Split(drainCandidates, ",")
hosts := strings.Split(hostList, ",")
_, result, err := r.DrainHosts(hosts...)
if err != nil {
fmt.Printf("error: %+v\n", err.Error())
@ -513,6 +513,20 @@ func main() {
}
fmt.Print(result.String())
case "endMaintenance":
fmt.Println("Setting hosts to ACTIVE")
if hostList == "" {
fmt.Println("No hosts specified to drain")
os.Exit(1)
}
hosts := strings.Split(hostList, ",")
_, result, err := r.EndMaintenance(hosts...)
if err != nil {
fmt.Printf("error: %+v\n", err.Error())
os.Exit(1)
}
fmt.Print(result.String())
default:
fmt.Println("Command not supported")
os.Exit(1)