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.
type HostStatus ¶
type HostStatus int
HostStatus represents status (Ready/Placing/Reserved/Held) of the host in host cache
const ( // ReadyHost represents a host ready to be used. ReadyHost HostStatus = iota + 1 // PlacingHost represents a host being used by placement engine. PlacingHost // ReservedHost represents a host that is reserved for tasks. ReservedHost )
const ( // ReadyHost represents a host ready to be used. ReadyHost HostStatus = iota + 1 // PlacingHost represents a host being used by placement engine. PlacingHost // ReservedHost represents a host that is reserved for tasks. ReservedHost // HeldHost represents a host hat is held for tasks, which is used for // in-place update. HeldHost )
type HostSummary ¶
type HostSummary interface { // TryMatch atomically tries to match the current host with given // HostFilter, and lock the host if it does. TryMatch(filter *hostmgr.HostFilter) Match // ReleasePodResources adds back resources to the current hostSummary. ReleasePodResources(ctx context.Context, podID string) // CompleteLease verifies that the leaseID on this host is still valid. CompleteLease(leaseID string, newPodToResMap map[string]scalar.Resources) error // CasStatus sets the status to new value if current value is old, otherwise // returns error. CasStatus(old, new HostStatus) error // GetCapacity returns the capacity of the host. GetCapacity() scalar.Resources // GetAllocated returns the allocation of the host. GetAllocated() scalar.Resources // SetCapacity sets the capacity of the host. SetCapacity(r scalar.Resources) // GetVersion returns the version of the host. GetVersion() string // SetVersion sets the version of the host. SetVersion(v string) // GetHostname returns the hostname of the host. GetHostname() string // GetHostStatus returns the HostStatus of the host. GetHostStatus() HostStatus // GetHostLease creates and returns a host lease. GetHostLease() *hostmgr.HostLease // TerminateLease is called when terminating the lease on a host. TerminateLease(leaseID string) error // HandlePodEvent is called when a pod event occurs for a pod // that affects this host. HandlePodEvent(event *p2kscalar.PodEvent) error }
type Match ¶
type Match struct { // The result of the match Result hostmgr.HostFilterResult // host name of the matched host HostName string }
Match represents the result of a match
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher keeps track of matched hosts for given constraints. This struct is not thread-safe.
func NewMatcher ¶
func NewMatcher(hostFilter *hostmgr.HostFilter) *Matcher
NewMatcher returns a new instance of Matcher.
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 ¶
NewMetrics returns a new Metrics struct, with all metrics initialized and rooted at the given tally.Scope
Source Files ¶
Click to show internal directories.
Click to hide internal directories.