-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd-info.go
56 lines (41 loc) · 1.05 KB
/
cmd-info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
log "github.com/Sirupsen/logrus"
"github.com/asteris-llc/gomarathon"
)
//Gets information about the Marathon cluster
func Info(host string) (*gomarathon.Response, error) {
m, _ := MarathonClient(host)
resp, err := m.Info()
if err != nil {
log.Error("Unable to get cluster information: ", err)
return resp, err
}
return resp, err
}
//Gets the current Leader
func Leader(host string) (*gomarathon.Response, error) {
m, _ := MarathonClient(host)
resp, err := m.Leader()
if err != nil {
log.Fatal("Leader data error: Make sure your hosts can resolve peer hostnames: ", err)
return nil, err
}
if resp.Code == 404 {
log.Info("No leader elected")
}
return resp, nil
}
//Forces current leader to step down
func DeleteLeader(host string) (*gomarathon.Response, error) {
m, _ := MarathonClient(host)
resp, err := m.DeleteLeader()
if err != nil {
log.Error("Error on Delete Leader request: ", err)
return nil, err
}
if resp.Code == 404 {
log.Error("Request for leader to step down failed")
}
return resp, err
}