Documentation ¶
Index ¶
- Constants
- type Health
- type Node
- type NodeURLBuilder
- type NodesNotFoundError
- type Tooler
- type Tools
- func (st *Tools) CloseUnitControllerConnection() error
- func (st *Tools) DetectIP() (string, error)
- func (st *Tools) Get(url string, timeout time.Duration) (body []byte, httpResponseCode int, err error)
- func (st *Tools) GetAgentNodes() (nodes []Node, err error)
- func (st *Tools) GetHostname() (string, error)
- func (st *Tools) GetJournalOutput(unit string) (string, error)
- func (st *Tools) GetMasterNodes() (nodesResponse []Node, err error)
- func (st *Tools) GetMesosNodeID() (string, error)
- func (st *Tools) GetNodeRole() (string, error)
- func (st *Tools) GetTimestamp() time.Time
- func (st *Tools) GetUnitNames() (units []string, err error)
- func (st *Tools) GetUnitProperties(pname string) (map[string]interface{}, error)
- func (st *Tools) InitializeUnitControllerConnection() (err error)
- func (st *Tools) Post(url string, timeout time.Duration) (body []byte, httpResponseCode int, err error)
- type URLBuilder
- type Unit
Constants ¶
const ( // Healthy indicates Unit is healthy Healthy = 0 // Unhealthy indicates Unit is not healthy Unhealthy = 1 // Unknown indicates Unit health could not be determined Unknown = 3 )
const ( // MasterRole DC/OS role for a master. MasterRole = dcos.RoleMaster // AgentRole DC/OS role for an agent. AgentRole = dcos.RoleAgent // AgentPublicRole DC/OS role for a public agent. AgentPublicRole = dcos.RoleAgentPublic )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { Leader bool Role string IP string Host string Health Health Output map[string]string Units []Unit `json:",omitempty"` MesosID string }
Node for DC/OS node.
type NodeURLBuilder ¶
NodeURLBuilder is an interface to define how to map from a node's IP and role to a URL to reach the node's HTTP API
type NodesNotFoundError ¶
type NodesNotFoundError struct {
// contains filtered or unexported fields
}
NodesNotFoundError is a custom error called when nodes are not found.
func (NodesNotFoundError) Error ¶
func (n NodesNotFoundError) Error() string
type Tooler ¶
type Tooler interface { // open dbus connection InitializeUnitControllerConnection() error // close dbus connection CloseUnitControllerConnection() error // function to get Connection.GetUnitProperties(pname) // returns a maps of properties https://github.com/coreos/go-systemd/blob/master/dbus/methods.go#L176 GetUnitProperties(string) (map[string]interface{}, error) // A wrapper to /opt/mesosphere/bin/detect_ip script // should return empty string if script fails. DetectIP() (string, error) // get system's hostname GetHostname() (string, error) // Detect node role: master/agent GetNodeRole() (string, error) // Get DC/OS systemd units on a system GetUnitNames() ([]string, error) // Get journal output GetJournalOutput(string) (string, error) // Get mesos node id, first argument is a function to determine a role. GetMesosNodeID() (string, error) // Get makes HTTP GET request, return read arrays of bytes Get(string, time.Duration) ([]byte, int, error) // Post makes HTTP GET request, return read arrays of bytes Post(string, time.Duration) ([]byte, int, error) // LookupMaster will lookup a masters in DC/OS cluster. // Initial lookup will be done by making HTTP GET request to exhibitor.If GET request fails, the next lookup // will failover to history service for one minute, it this fails or no nodes found, masters will be looked up // in history service for last hour. GetMasterNodes() ([]Node, error) // //// GetAgentsFromMaster will lookup agents in DC/OS cluster. GetAgentNodes() ([]Node, error) // Get timestamp GetTimestamp() time.Time }
Tooler DC/OS specific tools interface.
type Tools ¶
type Tools struct { sync.Mutex ExhibitorURL string Role string ForceTLS bool NodeInfo nodeutil.NodeInfo Transport http.RoundTripper // contains filtered or unexported fields }
Tools is implementation of Tooler interface.
func (*Tools) CloseUnitControllerConnection ¶
CloseUnitControllerConnection closes a dbus connection.
func (*Tools) DetectIP ¶
DetectIP returns a detected IP by running /opt/mesosphere/bin/detect_ip. It will run only once and cache the result. When the function is called again, ip will be taken from cache.
func (*Tools) Get ¶
func (st *Tools) Get(url string, timeout time.Duration) (body []byte, httpResponseCode int, err error)
Get HTTP request.
func (*Tools) GetAgentNodes ¶
GetAgentNodes finds DC/OS agents.
func (*Tools) GetHostname ¶
GetHostname return a localhost hostname.
func (*Tools) GetJournalOutput ¶
GetJournalOutput returns last 50 lines of journald command output for a specific systemd Unit.
func (*Tools) GetMasterNodes ¶
GetMasterNodes finds DC/OS masters.
func (*Tools) GetMesosNodeID ¶
GetMesosNodeID return a mesos node id.
func (*Tools) GetNodeRole ¶
GetNodeRole returns a nodes role. It will run only once and cache the result. When the function is called again, ip will be taken from cache.
func (*Tools) GetTimestamp ¶
GetTimestamp return time.Now()
func (*Tools) GetUnitNames ¶
GetUnitNames read a directory /etc/systemd/system/dcos.target.wants and return a list of found systemd units.
func (*Tools) GetUnitProperties ¶
GetUnitProperties return a map of systemd Unit properties received from dbus.
func (*Tools) InitializeUnitControllerConnection ¶
InitializeUnitControllerConnection opens a dbus connection. The connection is available via st.dcon
type URLBuilder ¶
type URLBuilder struct {
// contains filtered or unexported fields
}
URLBuilder implements NodeURLBuilder mapping agent and master roles to their configured ports and handling if the cluster requires TLS
func NewURLBuilder ¶
func NewURLBuilder(agentPort int, masterPort int, forceTLS bool) URLBuilder
NewURLBuilder constructs a NodeURLBuilder