dcos

package
v0.0.0-...-3641ea5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
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 Health

type Health int

Health is a type to indicates health of the unit.

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

type NodeURLBuilder interface {
	BaseURL(ip net.IP, role string) (string, error)
}

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

func (st *Tools) CloseUnitControllerConnection() error

CloseUnitControllerConnection closes a dbus connection.

func (*Tools) DetectIP

func (st *Tools) DetectIP() (string, error)

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

func (st *Tools) GetAgentNodes() (nodes []Node, err error)

GetAgentNodes finds DC/OS agents.

func (*Tools) GetHostname

func (st *Tools) GetHostname() (string, error)

GetHostname return a localhost hostname.

func (*Tools) GetJournalOutput

func (st *Tools) GetJournalOutput(unit string) (string, error)

GetJournalOutput returns last 50 lines of journald command output for a specific systemd Unit.

func (*Tools) GetMasterNodes

func (st *Tools) GetMasterNodes() (nodesResponse []Node, err error)

GetMasterNodes finds DC/OS masters.

func (*Tools) GetMesosNodeID

func (st *Tools) GetMesosNodeID() (string, error)

GetMesosNodeID return a mesos node id.

func (*Tools) GetNodeRole

func (st *Tools) GetNodeRole() (string, error)

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

func (st *Tools) GetTimestamp() time.Time

GetTimestamp return time.Now()

func (*Tools) GetUnitNames

func (st *Tools) GetUnitNames() (units []string, err error)

GetUnitNames read a directory /etc/systemd/system/dcos.target.wants and return a list of found systemd units.

func (*Tools) GetUnitProperties

func (st *Tools) GetUnitProperties(pname string) (map[string]interface{}, error)

GetUnitProperties return a map of systemd Unit properties received from dbus.

func (*Tools) InitializeUnitControllerConnection

func (st *Tools) InitializeUnitControllerConnection() (err error)

InitializeUnitControllerConnection opens a dbus connection. The connection is available via st.dcon

func (*Tools) Post

func (st *Tools) Post(url string, timeout time.Duration) (body []byte, httpResponseCode int, err error)

Post HTTP request.

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

func (*URLBuilder) BaseURL

func (n *URLBuilder) BaseURL(ip net.IP, role string) (string, error)

BaseURL will return the base URL for a node given its role and whether the cluster is configured to require TLS.

type Unit

type Unit struct {
	UnitName   string
	Nodes      []Node `json:",omitempty"`
	Health     Health
	Title      string
	Timestamp  time.Time
	PrettyName string
}

Unit for stands for systemd unit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL