host

package
v0.0.0-...-ac6a2c4 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHostInfoForRegisteredAgents

func BuildHostInfoForRegisteredAgents() (map[string]*pbhost.HostInfo, error)

BuildHostInfoForRegisteredAgents builds host infos for registered agents

func GetAgentInfo

func GetAgentInfo(hostname string) *mesos.AgentInfo

GetAgentInfo return agent info from global map.

func GetUpHostIP

func GetUpHostIP(hostname string) (string, error)

GetUpHostIP gets the IP address of a host in UP state

func IsHostRegistered

func IsHostRegistered(hostname string) bool

IsHostRegistered returns whether the host is registered

func IsRegisteredAsPelotonAgent

func IsRegisteredAsPelotonAgent(hostname, pelotonAgentRole string) bool

IsRegisteredAsPelotonAgent returns true if the host is registered as Peloton agent

Types

type AgentMap

type AgentMap struct {
	// Registered agent details by id.
	RegisteredAgents map[string]*mesos_master.Response_GetAgents_Agent

	// Resource capacity of all hosts.
	HostCapacities map[string]*ResourceCapacity

	Capacity      scalar.Resources
	SlackCapacity scalar.Resources
}

AgentMap is a placeholder from agent id to agent related information. Note that AgentInfo is immutable as of Mesos 1.3.

func GetAgentMap

func GetAgentMap() *AgentMap

GetAgentMap returns a full map of all registered agents. Note that caller should not mutable the content since it's not protected by any lock.

func (*AgentMap) ReportCapacityMetrics

func (a *AgentMap) ReportCapacityMetrics(scope tally.Scope)

ReportCapacityMetrics into given metric scope.

type Drainer

type Drainer interface {
	// Start the module
	Start()

	// Stop the module
	Stop()

	// GetDrainingHostInfos returns HostInfo of the specified DRAINING hosts.
	// If the hostFilter is empty then HostInfos of all DRAINING hosts
	// is returned.
	GetDrainingHostInfos(hostFilter []string) []*pbhost.HostInfo

	// GetDownHostInfos returns HostInfo of the specified DOWN hosts.
	// If the hostFilter is empty then HostInfos of all DOWN hosts
	// is returned.
	GetDownHostInfos(hostFilter []string) []*pbhost.HostInfo

	// StartMaintenance initiates putting a host into maintenance.
	StartMaintenance(ctx context.Context, hostname string) error

	// CompleteMaintenance brings a host out of maintenance.
	CompleteMaintenance(ctx context.Context, hostname string) error
}

Drainer defines the interface for host drainer

func NewDrainer

func NewDrainer(
	drainerPeriod time.Duration,
	pelotonAgentRole string,
	masterOperatorClient mpb.MasterOperatorClient,
	maintenanceQueue queue.MaintenanceQueue,
	hostInfoMap MaintenanceHostInfoMap,
) Drainer

NewDrainer creates a new host drainer

type Loader

type Loader struct {
	sync.Mutex
	OperatorClient     mpb.MasterOperatorClient
	SlackResourceTypes []string
	Scope              tally.Scope
	HostInfoOps        ormobjects.HostInfoOps // DB ops for host_info table
}

Loader loads hostmap from Mesos and stores in global singleton.

func (*Loader) Load

func (loader *Loader) Load(_ *uatomic.Bool)

Load hostmap into singleton.

type Matcher

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

Matcher keeps track of matched host offers for given constraints.

func NewMatcher

func NewMatcher(
	hostFilter *hostsvc.HostFilter,
	evaluator constraints.Evaluator,
	filter filterSlackResources) *Matcher

NewMatcher returns a new instance of Matcher. hostFilter defines the constraints on matching a host such as resources, revocable. evaluator is used to validate constraints such as labels.

func (*Matcher) GetMatchingHosts

func (m *Matcher) GetMatchingHosts() (map[string]*mesos.AgentInfo, *hostsvc.GetHostsFailure)

GetMatchingHosts tries to match the hosts through Host filter and it returns the hostname-> AgentInfo for the matched hosts. If the filter does not match, it returns the error

type Metrics

type Metrics struct {
	DrainingHosts tally.Gauge
	DownHosts     tally.Gauge
	// contains filtered or unexported fields
}

Metrics is placeholder for all metrics in hostmgr/host package.

func NewMetrics

func NewMetrics(scope tally.Scope) *Metrics

NewMetrics returns a new Metrics struct, with all metrics initialized and rooted at the given tally.Scope

type ResourceCapacity

type ResourceCapacity struct {
	// Physical capacity.
	Physical scalar.Resources
	// Revocable capacity.
	Slack scalar.Resources
}

ResourceCapacity contains total quantity of various kinds of host resources.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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