Skip to content

Commit

Permalink
Merge pull request #60 from storageos/feature/fix-cluster-health
Browse files Browse the repository at this point in the history
API updates for the fix-cluster-health feature
  • Loading branch information
domodwyer authored Feb 11, 2019
2 parents 5681952 + 5b37613 commit bf45d0f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions health.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ var (
HealthAPIPrefix = "health"
)

func (c *Client) ClusterHealth(ctx context.Context) ([]*types.ClusterHealthNode, error) {
status := []*types.ClusterHealthNode{}
url := fmt.Sprintf("/cluster/%s", HealthAPIPrefix)

resp, err := c.do("GET", url, doOptions{context: ctx})
if err != nil {
return nil, err
}
defer resp.Body.Close()

if err := json.NewDecoder(resp.Body).Decode(&status); err != nil {
return nil, err
}
return status, nil
}

// CPHealth returns the health of the control plane server at a given url.
func (c *Client) CPHealth(ctx context.Context, hostname string) (*types.CPHealthStatus, error) {

Expand Down
14 changes: 14 additions & 0 deletions types/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ type NamedSubModuleStatus struct {
SubModuleStatus
}

type ClusterHealthNode struct {
NodeID string `json:"nodeID"`
NodeName string `json:"nodeName"`
Submodules struct {
DirectFSInitiator SubModuleStatus `json:"directfs_initiator"`
Director SubModuleStatus `json:"director"`
KV SubModuleStatus `json:"kv"`
KVWrite SubModuleStatus `json:"kv_write"`
NATS SubModuleStatus `json:"nats"`
Presentation SubModuleStatus `json:"presentation"`
RDB SubModuleStatus `json:"rdb"`
} `json:"submodules"`
}

type CPHealthStatus struct {
KV SubModuleStatus
KVWrite SubModuleStatus
Expand Down

0 comments on commit bf45d0f

Please sign in to comment.