hostcache

package
v0.0.0-...-c0686e8 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostCache

type HostCache interface {
	// AcquireLeases acquires leases on hosts that match the filter constraints.
	AcquireLeases(hostFilter *hostmgr.HostFilter) ([]*hostmgr.HostLease, map[string]uint32)

	// TerminateLease is called when the lease is not going to be used, and we
	// want to release the lock on the host.
	TerminateLease(hostname string, leaseID string) error

	// CompleteLease is called when launching pods on a host that has been
	// previously leased to the Placement engine.
	CompleteLease(hostname string, leaseID string, podToSpecMap map[string]*pbpod.PodSpec) error

	// GetClusterCapacity gets the total capacity and allocation of the cluster.
	GetClusterCapacity() (capacity, allocation hmscalar.Resources)

	// Start will start the goroutine that listens for host events.
	Start()

	// Stop will stop the host cache go routine that listens for host events.
	Stop()

	// GetSummaries returns a list of host summaries that the host cache is
	// managing.
	GetSummaries() (summaries []hostsummary.HostSummary)

	// HandlePodEvent is called by pod events manager on receiving a pod event.
	HandlePodEvent(event *scalar.PodEvent)

	// ResetExpiredHeldHostSummaries resets the status of each hostSummary if
	// the helds have expired and returns the hostnames which got reset.
	ResetExpiredHeldHostSummaries(now time.Time) []string

	// GetHostHeldForPod returns the host that is held for the pod.
	GetHostHeldForPod(podID *peloton.PodID) string

	// HoldForPods holds the host for the pods specified.
	HoldForPods(hostname string, podIDs []*peloton.PodID) error

	// ReleaseHoldForPods release the hold of host for the pods specified.
	ReleaseHoldForPods(hostname string, podIDs []*peloton.PodID) error

	// CompleteLaunchPod is called when a pod is successfully launched.
	// This is for things like removing pods allocated to the pod
	// from available ports. This is called after successful launch
	// of individual pod. We cannot do this in CompleteLease.
	// For example, ports should not be removed after a failed launch,
	// otherwise the ports are leaked.
	CompleteLaunchPod(hostname string, pod *models.LaunchablePod) error

	// RecoverPodInfo updates pods info running on a particular host,
	// it is used only when hostsummary needs to recover the info
	// upon restart
	RecoverPodInfoOnHost(
		id *peloton.PodID,
		hostname string,
		state pbpod.PodState,
		spec *pbpod.PodSpec,
	)

	// AddPodsToHost is a temporary method to add host entries in host cache.
	// It would be removed after CompleteLease is called when launching pod.
	AddPodsToHost(tasks []*hostsvc.LaunchableTask, hostname string)
}

HostCache manages cluster resources, and provides necessary abstractions to interact with underlying system.

func New

func New(
	hostEventCh chan *scalar.HostEvent,
	backgroundMgr background.Manager,
	parent tally.Scope,
) HostCache

New returns a new instance of host cache.

type Metrics

type Metrics struct {
	// Available and Allocated resources in host cache.
	Available scalar.GaugeMaps
	Allocated scalar.GaugeMaps

	// Metrics for number of hosts on each status.
	ReadyHosts     tally.Gauge
	PlacingHosts   tally.Gauge
	HeldHosts      tally.Gauge
	AvailableHosts tally.Gauge
}

Metrics tracks various metrics at offer hostCache level.

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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