resource

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocatedStats

type AllocatedStats struct {

	// CPU is the currently allocated CPU as a percentage of the overall allocatable CPU resource
	// within a class.
	CPU float64

	// Memory is the currently allocated memory as a percentage of the overall allocatable memory
	// resource within a class.
	Memory float64
}

AllocatedStats is used to return information about the current allocated resources within a class as a percentage.

type Handler

type Handler interface {

	// GetNodeUpdateChan returns the channel where the node watcher should send updates regarding
	// the Nomad client cluster pool.
	GetNodeUpdateChan() chan interface{}

	// RunNodeUpdateHandler triggers the process which handles node updates and listens on the
	// channel as returned via GetNodeUpdateChan. When implementing this interface, the process
	// listening on the channel should expect a type of github.com/hashicorp/nomad/api/.(*Node).
	RunNodeUpdateHandler()

	// GetAllocUpdateChan returns the channel where the alloc watcher should send updates regarding
	// the Nomad cluster allocations.
	GetAllocUpdateChan() chan interface{}

	// RunAllocUpdateHandler triggers the process which handles node updates and listens on the
	// channel as returned via GetAllocUpdateChan. When implementing this interface, the process
	// listening on the channel should expect a type of
	// github.com/hashicorp/nomad/api/.(*Allocation).
	RunAllocUpdateHandler()

	// StopUpdateHandlers is used to stop all the running update handlers within the resource
	// process.
	StopUpdateHandlers()

	// GetNodesOfClass returns the currently stored node mapping relating to a particular class as
	// requested. The key of the map is the Nomad NodeID as specified by
	// github.com/hashicorp/nomad/api/.(*Node.ID).
	GetNodesOfClass(class string) map[string]*nodeInfo

	// GetClassResourceAllocation is used to perform allocation calculations for the class in
	// question. The function will use the stored class statistics to calculate the percentage of
	// resources currently allocated. The calculation uses allocated rather than actually used as
	// Nomad does not oversubscribe, and jobs will fail to run if there are not enough allocatable
	// resources.
	GetClassResourceAllocation(class string) (*AllocatedStats, error)

	// GetLeastAllocatedNodeInClass is used to find the node in the class pool which is the least
	// allocated. This is the current default and hardcoded mode for scaling in as it reduces the
	// amount of resources that need to be migrated across the cluster.
	GetLeastAllocatedNodeInClass(class string) *nodeInfo
}

Handler is the interface which governs how the Chemtrail resource manager state is interacted with. In order to lessen the load on the Nomad API, resource tracking is done via watchers, rather than API calls at the time they are needed. This means Chemtrail can make faster decisions and responses to requests, at a much lower impact to the Nomad cluster servers.

func NewHandler

func NewHandler(logger zerolog.Logger, nomad *client.Nomad) Handler

NewHandler creates a new resource handler for interactions with the resource state stored within Chemtrail based off updates from Nomad via watchers.

Jump to

Keyboard shortcuts

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