mesos

package
v0.0.0-...-11f2a26 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Hostname string `json:"hostname"`
	IP       string `json:"ip"`
	Port     int    `json:"port"`
}

Address represents a single address. e.g. from a Slave or from a Master

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Mesos client for DC/OS.

func NewClient

func NewClient(baseClient *httpclient.Client) *Client

NewClient creates a new Mesos client.

func NewClientWithContext

func NewClientWithContext(ctx api.Context) (*Client, error)

NewClientWithContext returns a client with a `baseURL` to communicate with Mesos.

func (*Client) Agents

func (c *Client) Agents() ([]master.Response_GetAgents_Agent, error)

Agents returns the agents of the mesos cluster.

func (*Client) Browse

func (c *Client) Browse(agent string, path string) ([]File, error)

Browse returns a file listing for an agent's directory

func (*Client) DeactivateAgent

func (c *Client) DeactivateAgent(agentID string) error

DeactivateAgent deactivates an agent.

func (*Client) Debug

func (c *Client) Debug(agent string) (map[string]string, error)

Debug returns the agent's internal virtual path mapping.

func (*Client) DeleteQuota

func (c *Client) DeleteQuota(quota string) error

DeleteQuota deletes a quota.

func (*Client) Download

func (c *Client) Download(agent string, filePath string) ([]byte, error)

Download returns bytes read from a file in the sandbox of a task at the location of filePath.

func (*Client) DrainAgent

func (c *Client) DrainAgent(agentID string, gracePeriod time.Duration, markGone bool) error

DrainAgent drains an agent.

func (*Client) Frameworks

func (c *Client) Frameworks() ([]master.Response_GetFrameworks_Framework, error)

Frameworks returns the frameworks of the connected cluster.

func (*Client) Hosts

func (c *Client) Hosts(host string) ([]Host, error)

Hosts returns the IP address(es) of an host.

func (*Client) Leader

func (c *Client) Leader() (*Master, error)

Leader returns the Mesos leader of the connected cluster.

func (*Client) MarkAgentGone

func (c *Client) MarkAgentGone(agentID string) error

MarkAgentGone marks an agent as gone.

func (*Client) Masters

func (c *Client) Masters() ([]Master, error)

Masters returns the Mesos masters of the connected cluster.

func (*Client) Quota

func (c *Client) Quota() (*master.Response_GetQuota, error)

Quota returns a quota.

func (*Client) ReactivateAgent

func (c *Client) ReactivateAgent(agentID string) error

ReactivateAgent reactivates an agent.

func (*Client) Roles

func (c *Client) Roles() (*Roles, error)

Roles returns a stripped down mesos/roles containing quota information.

func (*Client) State

func (c *Client) State() (*State, error)

State returns the current State of the Mesos master.

func (*Client) StateSummary

func (c *Client) StateSummary() (*StateSummary, error)

StateSummary returns a StateSummary of the Mesos master.

func (*Client) Tasks

func (c *Client) Tasks() ([]mesos.Task, error)

Tasks returns all the tasks known in a Mesos cluster.

func (*Client) TeardownFramework

func (c *Client) TeardownFramework(frameworkID string) error

TeardownFramework teardowns a framework.

func (*Client) UpdateQuota

func (c *Client) UpdateQuota(name string, cpu float64, disk float64, gpu float64, mem float64, force bool) error

UpdateQuota updates a quota.

type Container

type Container struct {
	Type   string `json:"type"`
	Docker Docker `json:"docker,omitempty"`
}

Container represents one way a Mesos task can be ran

type ContainerID

type ContainerID struct {
	Value  string       `json:"value"`
	Parent *ContainerID `json:"parent"`
}

ContainerID represents the ID of a container

type ContainerStatus

type ContainerStatus struct {
	ContainerID  ContainerID   `json:"container_id"`
	NetworkInfos []NetworkInfo `json:"network_infos"`
}

ContainerStatus represents the status of a single container inside a task

type Docker

type Docker struct {
	Image          string        `json:"image"`
	Network        string        `json:"network"`
	PortMappings   []PortMapping `json:"port_mappings"`
	Privileged     bool          `json:"privileged"`
	Parameters     []Parameter   `json:"parameters"`
	ForcePullImage bool          `json:"force_pull_image"`
}

Docker is one type of Container

type Domain

type Domain struct {
	FaultDomain struct {
		Region struct {
			Name string `json:"name"`
		} `json:"region"`
		Zone struct {
			Name string `json:"name"`
		} `json:"zone"`
	} `json:"fault_domain"`
}

Domain holds information about a nodes region and zone.

type Executor

type Executor struct {
	CompletedTasks []Task    `json:"completed_tasks"`
	Container      string    `json:"container"`
	Directory      string    `json:"directory"`
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	Resources      Resources `json:"resources"`
	Source         string    `json:"source"`
	QueuedTasks    []Task    `json:"queued_tasks"`
	Tasks          []Task    `json:"tasks"`
}

Executor represents a single executor of a framework

type File

type File struct {
	GID   string  `json:"gid"`
	Mode  string  `json:"mode"`
	MTime float64 `json:"mtime"`
	NLink float64 `json:"nlink"`
	Path  string  `json:"path"`
	Size  float64 `json:"size"`
	UID   string  `json:"uid"`
}

File represents an element returned when hitting the '/browse' endpoint.

type Framework

type Framework struct {
	Active             bool       `json:"active"`
	Capabilities       []string   `json:"capabilities"`
	Checkpoint         bool       `json:"checkpoint"`
	CompletedTasks     []Task     `json:"completed_tasks"`
	Executors          []Executor `json:"executors"`
	CompletedExecutors []Executor `json:"completed_executors"`
	FailoverTimeout    float64    `json:"failover_timeout"`
	Hostname           string     `json:"hostname"`
	ID                 string     `json:"id"`
	Name               string     `json:"name"`
	PID                string     `json:"pid"`
	OfferedResources   Resources  `json:"offered_resources"`
	Offers             []Offer    `json:"offers"`
	RegisteredTime     float64    `json:"registered_time"`
	ReregisteredTime   float64    `json:"reregistered_time"`
	Resources          Resources  `json:"resources"`
	Role               string     `json:"role"`
	Tasks              []Task     `json:"tasks"`
	UnregisteredTime   float64    `json:"unregistered_time"`
	UsedResources      Resources  `json:"used_resources"`
	User               string     `json:"user"`
	WebuiURL           string     `json:"webui_url"`
	Labels             []Label    `json:"label"`
}

Framework represent a single framework of a mesos node.

type Host

type Host struct {
	Host string `json:"host"`
	IP   string `json:"ip"`
}

Host holds information about a host and its IP.

type IPAddress

type IPAddress struct {
	IPAddress string `json:"ip_address"`
}

IPAddress represents a single IpAddress

type Label

type Label struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Label represents a single key / value pair for labeling

type Master

type Master struct {
	Host      string   `json:"host"`
	IP        string   `json:"ip"`
	PublicIPs []string `json:"public_ips"`
	Type      string   `json:"type"`
	Region    string   `json:"region"`
	Zone      string   `json:"zone"`
	ID        string   `json:"id"`
	PID       string   `json:"pid"`
	Version   string   `json:"version"`
}

Master represents a single mesos master node.

type NetworkInfo

type NetworkInfo struct {
	IPAddress   string      `json:"ip_address"`
	IPAddresses []IPAddress `json:"ip_addresses"`
}

NetworkInfo represents information about the network of a container

type Offer

type Offer struct {
	ID          string            `json:"id"`
	FrameworkID string            `json:"framework_id"`
	SlaveID     string            `json:"slave_id"`
	Hostname    string            `json:"hostname"`
	URL         URL               `json:"url"`
	Resources   Resources         `json:"resources"`
	Attributes  map[string]string `json:"attributes"`
}

Offer represents a single offer from a Mesos Slave to a Mesos master

type Parameter

type Parameter struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Parameter represents a single key / value pair for parameters

type PortDetails

type PortDetails struct {
	Number   int    `json:"number"`
	Protocol string `json:"protocol"`
}

PortDetails represents details about a single port

type PortMapping

type PortMapping struct {
	HostPort      int    `json:"host_port"`
	ContainerPort int    `json:"container_port"`
	Protocol      string `json:"protocol"`
}

PortMapping represents how containers ports map to host ports

type Ports

type Ports struct {
	Ports []PortDetails `json:"ports"`
}

Ports represents a number of PortDetails

type Quota

type Quota struct {
	Role      string                 `json:"role"`
	Consumed  map[string]interface{} `json:"consumed,omitempty"`
	Guarantee map[string]interface{} `json:"guarantee,omitempty"`
	Limit     map[string]interface{} `json:"limit,omitempty"`
}

Quota represents a role's quota

type Resources

type Resources struct {
	CPUs  float64 `json:"cpus"`
	Disk  float64 `json:"disk"`
	GPUs  float64 `json:"gpus"`
	Mem   float64 `json:"mem"`
	Ports string  `json:"ports"`
}

Resources represents a resource type for a task.

type Roles

type Roles struct {
	Roles []struct {
		Quota Quota `json:"quota"`
	} `json:"roles"`
}

Roles represents a stripped down representation of mesos/roles

type Slave

type Slave struct {
	TaskError           int                    `json:"TASK_ERROR"`
	TaskFailed          int                    `json:"TASK_FAILED"`
	TaskFinished        int                    `json:"TASK_FINISHED"`
	TaskKilled          int                    `json:"TASK_KILLED"`
	TaskKilling         int                    `json:"TASK_KILLING"`
	TaskLost            int                    `json:"TASK_LOST"`
	TaskRunning         int                    `json:"TASK_RUNNING"`
	TaskStaging         int                    `json:"TASK_STAGING"`
	TaskStarting        int                    `json:"TASK_STARTING"`
	TaskUnreachable     int                    `json:"TASK_UNREACHABLE"`
	Active              bool                   `json:"active"`
	Attributes          map[string]interface{} `json:"attributes"`
	Capabilities        []string               `json:"capabilities"`
	Domain              Domain                 `json:"domain"`
	FrameworkIDs        []string               `json:"framework_ids"`
	Hostname            string                 `json:"hostname"`
	PublicIPs           []string               `json:"public_ips"`
	ID                  string                 `json:"id"`
	PID                 string                 `json:"pid"`
	Port                int                    `json:"port"`
	Region              string                 `json:"region"`
	RegisteredTime      float64                `json:"registered_time"`
	Resources           Resources              `json:"resources"`
	UsedResources       Resources              `json:"used_resources"`
	OfferedResources    Resources              `json:"offered_resources"`
	ReservedResources   map[string]Resources   `json:"reserved_resources"`
	UnreservedResources Resources              `json:"unreserved_resources"`
	Type                string                 `json:"type"`
	Version             string                 `json:"version"`
	Zone                string                 `json:"zone"`
	Status              string                 `json:"status"`
}

Slave represents a single mesos slave node.

func (*Slave) IP

func (s *Slave) IP() string

IP returns the IP of a slave parsed from its PID.

type State

type State struct {
	Version             string      `json:"version"`
	ID                  string      `json:"id"`
	PID                 string      `json:"pid"`
	Hostname            string      `json:"hostname"`
	ActivatedSlaves     float64     `json:"activated_slaves"`
	DeactivatedSlaves   float64     `json:"deactivated_slaves"`
	Domain              Domain      `json:"domain"`
	Cluster             string      `json:"cluster"`
	Leader              string      `json:"leader"`
	Slaves              []Slave     `json:"slaves"`
	Frameworks          []Framework `json:"frameworks"`
	CompletedFrameworks []Framework `json:"completed_frameworks"`
}

State represents a state.json returned by a mesos master.

type StateSummary

type StateSummary struct {
	Hostname string
	Cluster  string
	Slaves   []Slave
}

StateSummary summarizes the state of a mesos master.

type Task

type Task struct {
	ExecutorID  string        `json:"executor_id"`
	FrameworkID string        `json:"framework_id"`
	ID          string        `json:"id"`
	Labels      []Label       `json:"labels"`
	Name        string        `json:"name"`
	Resources   Resources     `json:"resources"`
	SlaveID     string        `json:"slave_id"`
	State       string        `json:"state"`
	Statuses    []TaskStatus  `json:"statuses"`
	Discovery   TaskDiscovery `json:"discovery"`
	Container   Container     `json:"container"`
}

Task represent a single Mesos task

type TaskDiscovery

type TaskDiscovery struct {
	Visibility string `json:"visibility"`
	Name       string `json:"name"`
	Ports      Ports  `json:"ports"`
}

TaskDiscovery represents the discovery information of a task

type TaskIO

type TaskIO struct {
	// contains filtered or unexported fields
}

TaskIO is an abstraction used to stream I/O between a running Mesos task and the local terminal.

A TaskIO object can only be used for a single streaming session (through Attach or Exec), for subsequent streaming sessions one should instantiate new TaskIO objects.

func NewTaskIO

func NewTaskIO(containerID mesos.ContainerID, opts TaskIOOpts) (*TaskIO, error)

NewTaskIO creates a new TaskIO.

func (*TaskIO) Attach

func (t *TaskIO) Attach() (int, error)

Attach attaches the stdin/stdout/stderr of the CLI to the STDIN/STDOUT/STDERR of a running task.

As of now, we can only attach to tasks launched with a remote TTY already set up for them. If we try to attach to a task that was launched without a remote TTY attached, an error is returned.

func (*TaskIO) Exec

func (t *TaskIO) Exec(cmd string, args ...string) (int, error)

Exec launches a nested task based on the given command and attaches the stdin/stdout/stderr of the CLI to the STDIN/STDOUT/STDERR of the nested container.

type TaskIOOpts

type TaskIOOpts struct {
	Stdin             io.Reader
	Stdout            io.Writer
	Stderr            io.Writer
	Interactive       bool
	TTY               bool
	User              string
	HeartbeatInterval time.Duration
	EscapeSequence    []byte
	Sender            agentcalls.Sender
	Logger            *logrus.Logger
}

TaskIOOpts are options for a TaskIO.

type TaskStatus

type TaskStatus struct {
	State           string          `json:"state"`
	Timestamp       float64         `json:"timestamp"`
	ContainerStatus ContainerStatus `json:"container_status"`
}

TaskStatus represents the status of a single task

type URL

type URL struct {
	Scheme     string      `json:"scheme"`
	Address    Address     `json:"address"`
	Path       string      `json:"path"`
	Parameters []Parameter `json:"parameters"`
}

URL represents a single URL

Jump to

Keyboard shortcuts

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