scheduler

package
v0.0.0-...-29e6843 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// maximum turnaround we want to maintain for all hosts for a given distro
	MaxDurationPerDistroHost               = 30 * time.Minute
	MaxDurationPerDistroHostWithContainers = 5 * time.Minute

	// for distro queues with tasks that appear on other queues, this constant
	// indicates the fraction of the total duration of shared tasks that we want
	// to account for when alternate distros are unable to satisfy the
	// turnaround requirement as determined by MaxDurationPerDistroHost
	SharedTasksAllocationProportion = 0.8
)
View Source
const (
	RunnerName = "scheduler"
)

Variables

This section is empty.

Functions

func AlternateTaskFinder

func AlternateTaskFinder(distroID string) ([]task.Task, error)

func DeficitBasedHostAllocator

func DeficitBasedHostAllocator(ctx context.Context, hostAllocatorData HostAllocatorData) (int, error)

DeficitBasedHostAllocator decides how many new hosts are needed for a distro by seeing if the number of tasks that need to be run for the distro is greater than the number of hosts currently free to run a task. Returns a map of distro-># of hosts to spawn.

func DurationBasedHostAllocator

func DurationBasedHostAllocator(ctx context.Context, hostAllocatorData HostAllocatorData) (int, error)

NewHostsNeeded decides if new hosts are needed for a distro while taking the duration of running/scheduled tasks into consideration. Returns a map of distro to number of hosts to spawn.

func LegacyFindRunnableTasks

func LegacyFindRunnableTasks(distroID string) ([]task.Task, error)

The old Task finderDBTaskFinder, with the dependency check implemented in Go, instead of using $graphLookup

func ParallelTaskFinder

func ParallelTaskFinder(distroID string) ([]task.Task, error)

func PlanDistro

func PlanDistro(ctx context.Context, conf Configuration, s *evergreen.Settings) error

func RunnableTasksPipeline

func RunnableTasksPipeline(distroID string) ([]task.Task, error)

func UtilizationBasedHostAllocator

func UtilizationBasedHostAllocator(ctx context.Context, hostAllocatorData HostAllocatorData) (int, error)

Types

type CmpBasedTaskComparator

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

CmpBasedTaskComparator runs the tasks through a slice of comparator functions determining which is more important.

func NewCmpBasedTaskComparator

func NewCmpBasedTaskComparator() *CmpBasedTaskComparator

NewCmpBasedTaskComparator returns a new task prioritizer, using the default set of comparators as well as the setup functions necessary for those comparators.

func (*CmpBasedTaskComparator) Len

func (self *CmpBasedTaskComparator) Len() int

func (*CmpBasedTaskComparator) Less

func (self *CmpBasedTaskComparator) Less(i, j int) bool

func (*CmpBasedTaskComparator) Swap

func (self *CmpBasedTaskComparator) Swap(i, j int)

type CmpBasedTaskPrioritizer

type CmpBasedTaskPrioritizer struct{}

func (*CmpBasedTaskPrioritizer) PrioritizeTasks

func (prioritizer *CmpBasedTaskPrioritizer) PrioritizeTasks(distroId string, tasks []task.Task, versions map[string]version.Version) ([]task.Task, error)

PrioritizeTask prioritizes the tasks to run. First splits the tasks into slices based on whether they are part of patch versions or automatically created versions. Then prioritizes each slice, and merges them. Returns a full slice of the prioritized tasks, and an error if one occurs.

type CmpBasedTaskQueues

type CmpBasedTaskQueues struct {
	HighPriorityTasks []task.Task
	PatchTasks        []task.Task
	RepotrackerTasks  []task.Task
}

CmpBasedTaskQueues represents the three types of queues that are created for merging together into one queue. The HighPriorityTasks list represent the tasks that are always placed at the front of the queue PatchTasks and RepotrackerTasks are interleaved after the high priority tasks.

type Configuration

type Configuration struct {
	DistroID         string
	TaskFinder       string
	HostAllocator    string
	FreeHostFraction float64
}

type DBTaskQueuePersister

type DBTaskQueuePersister struct{}

DBTaskQueuePersister saves a queue to the database.

func (*DBTaskQueuePersister) PersistTaskQueue

func (self *DBTaskQueuePersister) PersistTaskQueue(distro string, tasks []task.Task) ([]model.TaskQueueItem, error)

PersistTaskQueue saves the task queue to the database. Returns an error if the db call returns an error.

type DistroScheduleData

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

DistroScheduleData contains bookkeeping data that is used by distros to determine whether or not to allocate more hosts

type HostAllocator

type HostAllocator func(context.Context, HostAllocatorData) (int, error)

HostAllocator is responsible for determining how many new hosts should be spun up. Parameters:

taskQueueItems: a map of distro name -> task queue items for that distro (a TaskQueue object)
distros: a map of distro name -> information on that distro (a model.Distro object)
existingDistroHosts: a map of distro name -> currently running hosts on that distro
projectTaskDurations: the expected duration of tasks by project and variant
taskRunDistros: a map of task id -> distros the task is allowed to run on

Returns a map of distro name -> how many hosts need to be spun up for that distro.

func GetHostAllocator

func GetHostAllocator(name string) HostAllocator

type HostAllocatorData

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

HostAllocatorData is the set of parameters passed to a HostAllocator.

type ScheduledDistroTasksData

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

ScheduledDistroTasksData contains data that is used to compute the expected duration of tasks within a distro's queue

type Scheduler

type Scheduler struct {
	*evergreen.Settings
	TaskPrioritizer
	TaskQueuePersister
	HostAllocator

	FindRunnableTasks TaskFinder
}

Responsible for prioritizing and scheduling tasks to be run, on a per-distro basis.

type TaskFinder

type TaskFinder func(string) ([]task.Task, error)

func GetTaskFinder

func GetTaskFinder(name string) TaskFinder

type TaskPrioritizer

type TaskPrioritizer interface {
	// Takes in a slice of tasks and the current MCI settings.
	// Returns the slice of tasks, sorted in the order in which they should
	// be run, as well as an error if appropriate.
	PrioritizeTasks(distroId string, tasks []task.Task, versions map[string]version.Version) ([]task.Task, error)
}

TaskPrioritizer is responsible for taking in a slice of tasks, and ordering them according to which should be run first.

type TaskQueuePersister

type TaskQueuePersister interface {
	// distro, tasks, duration cache
	PersistTaskQueue(string, []task.Task) ([]model.TaskQueueItem, error)
}

TaskQueuePersister is responsible for taking a task queue for a particular distro and saving it.

Jump to

Keyboard shortcuts

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