This repository has been archived by the owner on Feb 5, 2020. It is now read-only.
/
aws_status.go
66 lines (58 loc) · 1.61 KB
/
aws_status.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
57
58
59
60
61
62
63
64
65
66
package server
import (
"encoding/gob"
"encoding/json"
"sync"
"github.com/coreos/tectonic-installer/installer/server/aws/cloudforms"
)
func init() {
gob.Register(&TectonicAWSChecker{})
}
// TectonicAWSChecker is a serializable StatusChecker for Tectonic AWS
// clusters.
type TectonicAWSChecker struct {
AccessKeyID string
SecretAccessKey string
SessionToken string
Region string
ControllerDomain string
TectonicDomain string
Cluster *cloudforms.Cluster
}
// Status checks the state of AWS infrastructure, on-host kubelets, and
// Tectonic components in the cluster.
func (c TectonicAWSChecker) Status() ([]byte, error) {
type ClusterStatus struct {
CloudFormation cloudFormationStatus `json:"cloudFormation"`
Kubelet ServiceStatus `json:"kubelet"`
TectonicConsole ServiceStatus `json:"tectonicConsole"`
}
status := new(ClusterStatus)
client := defaultStatusClient
var wg sync.WaitGroup
wg.Add(3)
go func() {
defer wg.Done()
// create an AWS client Session
sess, err := getAWSSession(c.AccessKeyID, c.SecretAccessKey, c.SessionToken, c.Region)
if err == nil {
status.CloudFormation = cloudFormationHealth(c.Cluster, sess)
} else {
status.CloudFormation = cloudFormationStatus{
Message: err.Error(),
Error: true,
}
}
}()
go func() {
defer wg.Done()
status.Kubelet = KubeletHealth(client, c.ControllerDomain)
}()
go func() {
defer wg.Done()
status.TectonicConsole = TectonicConsoleHealth(client, c.TectonicDomain)
}()
// Wait for health checks to get responses or timeout
wg.Wait()
return json.Marshal(status)
}