summary

package
v0.0.0-...-a69e935 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 21 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostStatus

type HostStatus int

HostStatus represents status (Ready/Placing/Reserved) of the host in offer pool's cache (host -> offers).

const (
	// ReadyHost represents an host ready to be used.
	ReadyHost HostStatus = iota + 1
	// PlacingHost represents an host being used by placement engine.
	PlacingHost
	// ReservedHost represents an host is reserved for tasks
	ReservedHost
	// HeldHost represents a host is held for tasks, which is used for in-place update
	HeldHost
)

type HostSummary

type HostSummary interface {
	// HasOffer provides a quick heuristic about if HostSummary has any
	// unreserved READY offer.
	HasOffer() bool

	// HasAnyOffer returns true if host has any offer, including both reserved
	// and unreserved offer.
	HasAnyOffer() bool

	// GetTasks returns tasks placed or running on this host.
	GetTasks() []*mesos.TaskID

	// UpdateTasksOnHost updates the state of task placed or running on this host.
	// If task state is terminal then remove from HostToTaskMap.
	UpdateTasksOnHost(taskID string, taskState task.TaskState, taskInfo *task.TaskInfo)

	// TryMatch atomically tries to match offers from the current host with
	// given constraint.
	TryMatch(
		hostFilter *hostsvc.HostFilter,
		evaluator constraints.Evaluator,
		labelValues constraints.LabelValues) Match

	// AddMesosOffer adds a Mesos offers to the current HostSummary.
	AddMesosOffers(ctx context.Context, offer []*mesos.Offer) HostStatus

	// RemoveMesosOffer removes the given Mesos offer by its id, and returns
	// CacheStatus and possibly removed offer for tracking purpose.
	RemoveMesosOffer(offerID, reason string) (HostStatus, *mesos.Offer)

	// ClaimForLaunch releases unreserved offers for task launch.
	// An optional list of task ids is provided if the host is held for
	// the tasks
	ClaimForLaunch(
		hostOfferID string,
		launchableTasks []*hostsvc.LaunchableTask,
		taskIDs ...*peloton.TaskID) (map[string]*mesos.Offer, error)

	// CasStatus atomically sets the status to new value if current value is old,
	// otherwise returns error.
	CasStatus(old, new HostStatus) error

	// UnreservedAmount returns unreserved non-revocable and revocable resources
	// and current host status
	UnreservedAmount() (scalar.Resources, scalar.Resources, HostStatus)

	// ResetExpiredPlacingOfferStatus resets a hostSummary status from PlacingOffer
	// if the PlacingOffer status has expired, and returns
	// whether the hostSummary got reset, resources amount for unreserved offers and
	// the tasks held released due to the expiration
	ResetExpiredPlacingOfferStatus(now time.Time) (bool, scalar.Resources, []*peloton.TaskID)

	// ResetExpiredHostHeldStatus resets a hostSummary status from HeldHost
	// if the HeldHost status has expired, and returns
	// whether the hostSummary got reset, resources amount for unreserved offers and
	// the tasks held released due to the expiration
	ResetExpiredHostHeldStatus(now time.Time) (bool, scalar.Resources, []*peloton.TaskID)

	// GetOffers returns offers and #offers present for this host, of type reserved, unreserved or all.
	// Returns map of offerid -> offer
	GetOffers(OfferType) map[string]*mesos.Offer

	// GetHostname returns the hostname of the host
	GetHostname() string

	// GetHostStatus returns the HostStatus of the host
	GetHostStatus() HostStatus

	// GetHostOfferID returns the hostOfferID of the host
	GetHostOfferID() string

	// HoldForTasks holds the host for the task specified.
	// If an error is returned, hostsummary would guarantee that
	// the host is not on held for the task
	HoldForTask(id *peloton.TaskID) error

	// ReleaseHoldForTasks release the hold of host for the task specified.
	// If an error is returned, hostsummary would guarantee that
	// the host is not on released for the task
	ReleaseHoldForTask(id *peloton.TaskID) error

	// ReturnPlacingHost is called when the host in PLACING state is not used,
	// and is returned by placement engine
	ReturnPlacingHost() error

	// GetHeldTask returns a slice of task that puts the host in held
	GetHeldTask() []*peloton.TaskID
}

HostSummary is the core component of host manager's internal data structure. It keeps track of offers in various state, launching cycles and reservation information for a host.

func New

func New(
	scarceResourceTypes []string,
	hostname string,
	slackResourceTypes []string,
	hostPlacingOfferStatusTimeout time.Duration,
	processor watchevent.WatchProcessor,
) HostSummary

New returns a zero initialized hostSummary

type InvalidHostStatus

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

InvalidHostStatus is returned when expected status on a hostSummary does not match actual value.

func (InvalidHostStatus) Error

func (e InvalidHostStatus) Error() string

Error implements error.Error.

type Match

type Match struct {
	// The result of the match
	Result hostsvc.HostFilterResult
	// Offer if the match is successful
	Offer *Offer
}

Match represents the result of a match

type Offer

type Offer struct {
	ID     string
	Offers []*mesos.Offer
}

Offer represents an offer sent from the host summary when the host is moved to PLACING state.

Evey offer sent has a unique ID which is used to to claim the offer for launching a task. The ID is reset when the host moves to READY state.

The ID is not persisted and is reset when a hostmanager restarts, remaining in flight tasks will have to placed again and generate new ID for the offers.

type OfferType

type OfferType int

OfferType represents the type of offer in the host summary such as reserved, unreserved, or All.

const (
	// Reserved offer type, represents an offer reserved for a particular Mesos Role.
	Reserved OfferType = iota + 1
	// Unreserved offer type, is not reserved for any Mesos role, and can be used to launch task for
	// any role if framework has opt-in MULTI_ROLE capability.
	Unreserved
	// All represents reserved and unreserved offers.
	All
)

Jump to

Keyboard shortcuts

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