cache

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddOccupiedResource updateType = iota
	SubOccupiedResource
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AStates added in v1.1.0

type AStates struct {
	New        string
	Recovering string
	Submitted  string
	Accepted   string
	Reserving  string
	Running    string
	Rejected   string
	Completed  string
	Killing    string
	Killed     string
	Failing    string
	Failed     string
	Resuming   string
}

func ApplicationStates added in v1.1.0

func ApplicationStates() *AStates

type AllocatedTaskEvent

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

------------------------ Allocate Event ------------------------

func NewAllocateTaskEvent

func NewAllocateTaskEvent(appID string, taskID string, allocUUID string, nid string) AllocatedTaskEvent

func (AllocatedTaskEvent) GetApplicationID

func (ae AllocatedTaskEvent) GetApplicationID() string

func (AllocatedTaskEvent) GetArgs

func (ae AllocatedTaskEvent) GetArgs() []interface{}

func (AllocatedTaskEvent) GetEvent

func (ae AllocatedTaskEvent) GetEvent() string

func (AllocatedTaskEvent) GetTaskID

func (ae AllocatedTaskEvent) GetTaskID() string

type Application

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

func NewApplication

func NewApplication(appID, queueName, user string, groups []string, tags map[string]string, scheduler api.SchedulerAPI) *Application

func (*Application) GetAllocatedTasks

func (app *Application) GetAllocatedTasks() []*Task

func (*Application) GetApplicationID

func (app *Application) GetApplicationID() string

func (*Application) GetApplicationState

func (app *Application) GetApplicationState() string

func (*Application) GetBoundTasks added in v1.3.0

func (app *Application) GetBoundTasks() []*Task

func (*Application) GetNewTasks

func (app *Application) GetNewTasks() []*Task

func (*Application) GetOriginatingTask added in v1.1.0

func (app *Application) GetOriginatingTask() interfaces.ManagedTask

func (*Application) GetPendingTasks

func (app *Application) GetPendingTasks() []*Task

func (*Application) GetPlaceHolderTasks added in v1.1.0

func (app *Application) GetPlaceHolderTasks() []*Task

func (*Application) GetQueue

func (app *Application) GetQueue() string

func (*Application) GetSchedulingParamsDefinition

func (app *Application) GetSchedulingParamsDefinition() string

func (*Application) GetTags

func (app *Application) GetTags() map[string]string

func (*Application) GetTask

func (app *Application) GetTask(taskID string) (interfaces.ManagedTask, error)

func (*Application) GetTaskGroupsDefinition

func (app *Application) GetTaskGroupsDefinition() string

func (*Application) GetUser

func (app *Application) GetUser() string

func (*Application) Schedule

func (app *Application) Schedule() bool

Schedule is called in every scheduling interval, we are not using dispatcher here because we want to make state transition in sync mode in order to prevent generating too many duplicate events. However, it must ensure non of these calls is expensive, usually, they do nothing more than just triggering the state transition. return true if the app needs scheduling or false if not

func (*Application) SetPlaceholderTimeout

func (app *Application) SetPlaceholderTimeout(timeout int64)

func (*Application) SetState

func (app *Application) SetState(state string)

SetState is only for testing this is just used for testing, it is not supposed to change state like this

func (*Application) String

func (app *Application) String() string

func (*Application) TriggerAppRecovery

func (app *Application) TriggerAppRecovery() error

type ApplicationEvent

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

------------------------ ApplicationEvent is used for testing and rejected app's events ------------------------

func NewApplicationEvent

func NewApplicationEvent(appID string, eventType ApplicationEventType, msg string) ApplicationEvent

func (ApplicationEvent) GetApplicationID

func (st ApplicationEvent) GetApplicationID() string

func (ApplicationEvent) GetArgs

func (st ApplicationEvent) GetArgs() []interface{}

func (ApplicationEvent) GetEvent

func (st ApplicationEvent) GetEvent() string

type ApplicationEventType added in v1.1.0

type ApplicationEventType int

---------------------------------------------- Application events ----------------------------------------------

const (
	SubmitApplication ApplicationEventType = iota
	RecoverApplication
	AcceptApplication
	TryReserve
	UpdateReservation
	RunApplication
	RejectApplication
	CompleteApplication
	FailApplication
	KillApplication
	KilledApplication
	ReleaseAppAllocation
	ReleaseAppAllocationAsk
	AppStateChange
	ResumingApplication
	AppTaskCompleted
)

func (ApplicationEventType) String added in v1.1.0

func (ae ApplicationEventType) String() string

type ApplicationStatusChangeEvent

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

------------------------ ApplicationStatusChangeEvent updates the status in the application CRD ------------------------

func NewApplicationStatusChangeEvent

func NewApplicationStatusChangeEvent(appID string, eventType ApplicationEventType, state string) ApplicationStatusChangeEvent

func (ApplicationStatusChangeEvent) GetApplicationID

func (st ApplicationStatusChangeEvent) GetApplicationID() string

func (ApplicationStatusChangeEvent) GetArgs

func (st ApplicationStatusChangeEvent) GetArgs() []interface{}

func (ApplicationStatusChangeEvent) GetEvent

func (st ApplicationStatusChangeEvent) GetEvent() string

func (ApplicationStatusChangeEvent) GetState

func (st ApplicationStatusChangeEvent) GetState() string

type BindTaskEvent

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

------------------------ Bound Event ------------------------

func NewBindTaskEvent

func NewBindTaskEvent(appID string, taskID string) BindTaskEvent

func (BindTaskEvent) GetApplicationID

func (bt BindTaskEvent) GetApplicationID() string

func (BindTaskEvent) GetArgs

func (bt BindTaskEvent) GetArgs() []interface{}

func (BindTaskEvent) GetEvent

func (bt BindTaskEvent) GetEvent() string

func (BindTaskEvent) GetTaskID

func (bt BindTaskEvent) GetTaskID() string

type CachedSchedulerNodeEvent

type CachedSchedulerNodeEvent struct {
	NodeID string
	Event  SchedulerNodeEventType
}

func (CachedSchedulerNodeEvent) GetArgs

func (sn CachedSchedulerNodeEvent) GetArgs() []interface{}

func (CachedSchedulerNodeEvent) GetEvent

func (sn CachedSchedulerNodeEvent) GetEvent() string

func (CachedSchedulerNodeEvent) GetNodeID

func (sn CachedSchedulerNodeEvent) GetNodeID() string

type Context

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

context maintains scheduling state, like apps and apps' tasks.

func NewContext

func NewContext(apis client.APIProvider) *Context

NewContext create a new context for the scheduler using a default (empty) configuration VisibleForTesting

func NewContextWithBootstrapConfigMaps added in v1.3.0

func NewContextWithBootstrapConfigMaps(apis client.APIProvider, bootstrapConfigMaps []*v1.ConfigMap) *Context

NewContextWithBootstrapConfigMaps creates a new context for the scheduler using configuration bootstrapped from Kubernetes ConfigMaps

func (*Context) AddApplication

func (ctx *Context) AddApplication(request *interfaces.AddApplicationRequest) interfaces.ManagedApp

func (*Context) AddPendingPodAllocation

func (ctx *Context) AddPendingPodAllocation(podKey string, nodeID string)

func (*Context) AddSchedulingEventHandlers

func (ctx *Context) AddSchedulingEventHandlers()

func (*Context) AddTask

func (ctx *Context) AddTask(request *interfaces.AddTaskRequest) interfaces.ManagedTask

this implements ApplicationManagementProtocol

func (*Context) ApplicationEventHandler

func (ctx *Context) ApplicationEventHandler() func(obj interface{})

func (*Context) AssumePod

func (ctx *Context) AssumePod(name string, node string) error

assume a pod will be running on a node, in scheduler, we maintain a cache where stores info for each node what pods are supposed to be running on it. And we keep this cache in-sync between core and the shim. this way, the core can make allocation decisions with consideration of other assumed pods before they are actually bound to the node (bound is slow).

func (*Context) ForgetPod

func (ctx *Context) ForgetPod(name string)

forget pod must be called when a pod is assumed to be running on a node, but then for some reason it is failed to bind or released.

func (*Context) GetAllApplications added in v1.3.0

func (ctx *Context) GetAllApplications() []*Application

func (*Context) GetApplication

func (ctx *Context) GetApplication(appID string) interfaces.ManagedApp

func (*Context) GetInProgressPodAllocation

func (ctx *Context) GetInProgressPodAllocation(podKey string) (nodeID string, ok bool)

func (*Context) GetPendingPodAllocation

func (ctx *Context) GetPendingPodAllocation(podKey string) (nodeID string, ok bool)

func (*Context) GetSchedulerCache added in v1.3.0

func (ctx *Context) GetSchedulerCache() *schedulercache.SchedulerCache

VisibleForTesting

func (*Context) GetStateDump added in v1.2.0

func (ctx *Context) GetStateDump() (string, error)

func (*Context) HandleContainerStateUpdate

func (ctx *Context) HandleContainerStateUpdate(request *si.UpdateContainerSchedulingStateRequest)

this function handles the pod scheduling failures with respect to the different causes, and update the pod condition accordingly. the cluster autoscaler depends on the certain pod condition in order to trigger auto-scaling.

func (*Context) IsPluginMode

func (ctx *Context) IsPluginMode() bool

func (*Context) IsPodFitNode

func (ctx *Context) IsPodFitNode(name, node string, allocate bool) error

evaluate given predicates based on current context

func (*Context) IsPodFitNodeViaPreemption added in v1.3.0

func (ctx *Context) IsPodFitNodeViaPreemption(name, node string, allocations []string, startIndex int) (index int, ok bool)

func (*Context) IsPreemptSelfAllowed added in v1.2.0

func (ctx *Context) IsPreemptSelfAllowed(priorityClassName string) bool

func (*Context) LoadConfigMaps added in v1.2.0

func (ctx *Context) LoadConfigMaps() ([]*v1.ConfigMap, error)

func (*Context) NotifyApplicationComplete

func (ctx *Context) NotifyApplicationComplete(appID string)

inform the scheduler that the application is completed, the complete state may further explained to completed_with_errors(failed) or successfully_completed, either way we need to release all allocations (if exists) for this application

func (*Context) NotifyApplicationFail

func (ctx *Context) NotifyApplicationFail(appID string)

func (*Context) NotifyTaskComplete

func (ctx *Context) NotifyTaskComplete(appID, taskID string)

func (*Context) PublishEvents

func (ctx *Context) PublishEvents(eventRecords []*si.EventRecord)

func (*Context) RemoveApplication

func (ctx *Context) RemoveApplication(appID string) error

func (*Context) RemoveApplicationInternal

func (ctx *Context) RemoveApplicationInternal(appID string)

func (*Context) RemovePodAllocation

func (ctx *Context) RemovePodAllocation(podKey string)

func (*Context) RemoveTask

func (ctx *Context) RemoveTask(appID, taskID string)

func (*Context) SchedulerNodeEventHandler

func (ctx *Context) SchedulerNodeEventHandler() func(obj interface{})

func (*Context) SetPluginMode

func (ctx *Context) SetPluginMode(pluginMode bool)

func (*Context) StartPodAllocation

func (ctx *Context) StartPodAllocation(podKey string, nodeID string) bool

func (*Context) TaskEventHandler

func (ctx *Context) TaskEventHandler() func(obj interface{})

func (*Context) UpdateApplication

func (ctx *Context) UpdateApplication(app *Application)

func (*Context) WaitForRecovery

func (ctx *Context) WaitForRecovery(recoverableAppManagers []interfaces.Recoverable, maxTimeout time.Duration) error

type FailApplicationEvent

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

------------------------ Fail application ------------------------

func NewFailApplicationEvent

func NewFailApplicationEvent(appID, message string) FailApplicationEvent

func (FailApplicationEvent) GetApplicationID

func (fe FailApplicationEvent) GetApplicationID() string

func (FailApplicationEvent) GetArgs

func (fe FailApplicationEvent) GetArgs() []interface{}

func (FailApplicationEvent) GetEvent

func (fe FailApplicationEvent) GetEvent() string

type FailTaskEvent

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

------------------------ Fail Event ------------------------

func NewFailTaskEvent

func NewFailTaskEvent(appID string, taskID string, failedMessage string) FailTaskEvent

func (FailTaskEvent) GetApplicationID

func (fe FailTaskEvent) GetApplicationID() string

func (FailTaskEvent) GetArgs

func (fe FailTaskEvent) GetArgs() []interface{}

func (FailTaskEvent) GetEvent

func (fe FailTaskEvent) GetEvent() string

func (FailTaskEvent) GetTaskID

func (fe FailTaskEvent) GetTaskID() string

type MockedAMProtocol

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

implements ApplicationManagementProtocol

func NewMockedAMProtocol

func NewMockedAMProtocol() *MockedAMProtocol

func (*MockedAMProtocol) AddApplication

func (*MockedAMProtocol) AddTask

func (*MockedAMProtocol) GetApplication

func (m *MockedAMProtocol) GetApplication(appID string) interfaces.ManagedApp

func (*MockedAMProtocol) NotifyApplicationComplete

func (m *MockedAMProtocol) NotifyApplicationComplete(appID string)

func (*MockedAMProtocol) NotifyApplicationFail

func (m *MockedAMProtocol) NotifyApplicationFail(appID string)

func (*MockedAMProtocol) NotifyTaskComplete

func (m *MockedAMProtocol) NotifyTaskComplete(appID, taskID string)

func (*MockedAMProtocol) RemoveApplication

func (m *MockedAMProtocol) RemoveApplication(appID string) error

func (*MockedAMProtocol) RemoveTask

func (m *MockedAMProtocol) RemoveTask(appID, taskID string)

func (*MockedAMProtocol) UseAddTaskFn added in v1.1.0

func (m *MockedAMProtocol) UseAddTaskFn(fn func(request *interfaces.AddTaskRequest))

type NStates added in v1.1.0

type NStates struct {
	New        string
	Recovering string
	Accepted   string
	Healthy    string
	Rejected   string
	Draining   string
}

func SchedulerNodeStates added in v1.1.0

func SchedulerNodeStates() *NStates

type Placeholder

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

func (*Placeholder) String

func (p *Placeholder) String() string

type PlaceholderManager

type PlaceholderManager struct {

	// a simple mutex will do we do not have separate read and write paths
	sync.RWMutex
	// contains filtered or unexported fields
}

PlaceholderManager is a service to manage the lifecycle of app placeholders

func NewPlaceholderManager

func NewPlaceholderManager(clients *client.Clients) *PlaceholderManager

func (*PlaceholderManager) Start

func (mgr *PlaceholderManager) Start()

func (*PlaceholderManager) Stop

func (mgr *PlaceholderManager) Stop()

type RejectTaskEvent

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

------------------------ Reject Event ------------------------

func NewRejectTaskEvent

func NewRejectTaskEvent(appID string, taskID string, rejectedMessage string) RejectTaskEvent

func (RejectTaskEvent) GetApplicationID

func (re RejectTaskEvent) GetApplicationID() string

func (RejectTaskEvent) GetArgs

func (re RejectTaskEvent) GetArgs() []interface{}

func (RejectTaskEvent) GetEvent

func (re RejectTaskEvent) GetEvent() string

func (RejectTaskEvent) GetTaskID

func (re RejectTaskEvent) GetTaskID() string

type ReleaseAppAllocationAskEvent

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

func NewReleaseAppAllocationAskEvent

func NewReleaseAppAllocationAskEvent(appID string, allocTermination si.TerminationType, taskID string) ReleaseAppAllocationAskEvent

func (ReleaseAppAllocationAskEvent) GetApplicationID

func (re ReleaseAppAllocationAskEvent) GetApplicationID() string

func (ReleaseAppAllocationAskEvent) GetArgs

func (re ReleaseAppAllocationAskEvent) GetArgs() []interface{}

func (ReleaseAppAllocationAskEvent) GetEvent

func (re ReleaseAppAllocationAskEvent) GetEvent() string

type ReleaseAppAllocationEvent

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

------------------------ Release application allocations ------------------------

func NewReleaseAppAllocationEvent

func NewReleaseAppAllocationEvent(appID string, allocTermination si.TerminationType, uuid string) ReleaseAppAllocationEvent

func (ReleaseAppAllocationEvent) GetApplicationID

func (re ReleaseAppAllocationEvent) GetApplicationID() string

func (ReleaseAppAllocationEvent) GetArgs

func (re ReleaseAppAllocationEvent) GetArgs() []interface{}

func (ReleaseAppAllocationEvent) GetEvent

func (re ReleaseAppAllocationEvent) GetEvent() string

type ResumingApplicationEvent

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

------------------------ Resuming application ------------------------

func NewResumingApplicationEvent

func NewResumingApplicationEvent(appID string) ResumingApplicationEvent

func (ResumingApplicationEvent) GetApplicationID

func (re ResumingApplicationEvent) GetApplicationID() string

func (ResumingApplicationEvent) GetArgs

func (re ResumingApplicationEvent) GetArgs() []interface{}

func (ResumingApplicationEvent) GetEvent

func (re ResumingApplicationEvent) GetEvent() string

type RunApplicationEvent

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

------------------------ Run application ------------------------

func NewRunApplicationEvent

func NewRunApplicationEvent(appID string) RunApplicationEvent

func (RunApplicationEvent) GetApplicationID

func (re RunApplicationEvent) GetApplicationID() string

func (RunApplicationEvent) GetArgs

func (re RunApplicationEvent) GetArgs() []interface{}

func (RunApplicationEvent) GetEvent

func (re RunApplicationEvent) GetEvent() string

type SchedulerNode

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

stores info about what scheduler cares about a node

type SchedulerNodeEventType added in v1.1.0

type SchedulerNodeEventType int

---------------------------------------------- SchedulerNode events ----------------------------------------------

const (
	RecoverNode SchedulerNodeEventType = iota
	NodeAccepted
	NodeRejected
	DrainNode
	RestoreNode
	NodeReady
)

func (SchedulerNodeEventType) String added in v1.1.0

func (ae SchedulerNodeEventType) String() string

type SimpleApplicationEvent

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

------------------------ SimpleApplicationEvent simply moves application states ------------------------

func NewSimpleApplicationEvent

func NewSimpleApplicationEvent(appID string, eventType ApplicationEventType) SimpleApplicationEvent

func (SimpleApplicationEvent) GetApplicationID

func (st SimpleApplicationEvent) GetApplicationID() string

func (SimpleApplicationEvent) GetArgs

func (st SimpleApplicationEvent) GetArgs() []interface{}

func (SimpleApplicationEvent) GetEvent

func (st SimpleApplicationEvent) GetEvent() string

type SimpleTaskEvent

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

------------------------ Simple task Event simply moves task to next state, it has no arguments provided ------------------------

func NewSimpleTaskEvent

func NewSimpleTaskEvent(appID string, taskID string, taskType TaskEventType) SimpleTaskEvent

func (SimpleTaskEvent) GetApplicationID

func (st SimpleTaskEvent) GetApplicationID() string

func (SimpleTaskEvent) GetArgs

func (st SimpleTaskEvent) GetArgs() []interface{}

func (SimpleTaskEvent) GetEvent

func (st SimpleTaskEvent) GetEvent() string

func (SimpleTaskEvent) GetTaskID

func (st SimpleTaskEvent) GetTaskID() string

type SubmitApplicationEvent

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

------------------------ SubmitTask application ------------------------

func NewSubmitApplicationEvent

func NewSubmitApplicationEvent(appID string) SubmitApplicationEvent

func (SubmitApplicationEvent) GetApplicationID

func (se SubmitApplicationEvent) GetApplicationID() string

func (SubmitApplicationEvent) GetArgs

func (se SubmitApplicationEvent) GetArgs() []interface{}

func (SubmitApplicationEvent) GetEvent

func (se SubmitApplicationEvent) GetEvent() string

type SubmitTaskEvent

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

------------------------ SubmitTask Event ------------------------

func NewSubmitTaskEvent

func NewSubmitTaskEvent(appID string, taskID string) SubmitTaskEvent

func (SubmitTaskEvent) GetApplicationID

func (st SubmitTaskEvent) GetApplicationID() string

func (SubmitTaskEvent) GetArgs

func (st SubmitTaskEvent) GetArgs() []interface{}

func (SubmitTaskEvent) GetEvent

func (st SubmitTaskEvent) GetEvent() string

func (SubmitTaskEvent) GetTaskID

func (st SubmitTaskEvent) GetTaskID() string

type TStates added in v1.1.0

type TStates struct {
	New        string
	Pending    string
	Scheduling string
	Allocated  string
	Rejected   string
	Bound      string
	Killing    string
	Killed     string
	Failed     string
	Completed  string
	Any        []string // Any refers to all possible states
	Terminated []string // Rejected, Killed, Failed, Completed
}

func TaskStates added in v1.1.0

func TaskStates() *TStates

type Task

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

func NewFromTaskMeta

func NewFromTaskMeta(tid string, app *Application, ctx *Context, metadata interfaces.TaskMetadata, originator bool) *Task

func NewTask

func NewTask(tid string, app *Application, ctx *Context, pod *v1.Pod) *Task

func NewTaskPlaceholder

func NewTaskPlaceholder(tid string, app *Application, ctx *Context, pod *v1.Pod) *Task

func (*Task) DeleteTaskPod

func (task *Task) DeleteTaskPod(pod *v1.Pod) error

func (*Task) GetTaskID

func (task *Task) GetTaskID() string

func (*Task) GetTaskPod

func (task *Task) GetTaskPod() *v1.Pod

func (*Task) GetTaskState

func (task *Task) GetTaskState() string

func (*Task) IsOriginator added in v1.1.0

func (task *Task) IsOriginator() bool

func (*Task) IsPlaceholder

func (task *Task) IsPlaceholder() bool

func (*Task) UpdateTaskPod added in v1.2.0

func (task *Task) UpdateTaskPod(pod *v1.Pod, podMutator func(pod *v1.Pod)) (*v1.Pod, error)

func (*Task) UpdateTaskPodStatus

func (task *Task) UpdateTaskPodStatus(pod *v1.Pod) (*v1.Pod, error)

type TaskEventType added in v1.1.0

type TaskEventType int

---------------------------------------------- Task events ----------------------------------------------

const (
	InitTask TaskEventType = iota
	SubmitTask
	TaskAllocated
	TaskRejected
	TaskBound
	CompleteTask
	TaskFail
	KillTask
	TaskKilled
)

func (TaskEventType) String added in v1.1.0

func (ae TaskEventType) String() string

type UpdateApplicationReservationEvent

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

------------------------ Reservation Update Event ------------------------

func NewUpdateApplicationReservationEvent

func NewUpdateApplicationReservationEvent(appID string) UpdateApplicationReservationEvent

func (UpdateApplicationReservationEvent) GetApplicationID

func (ue UpdateApplicationReservationEvent) GetApplicationID() string

func (UpdateApplicationReservationEvent) GetArgs

func (ue UpdateApplicationReservationEvent) GetArgs() []interface{}

func (UpdateApplicationReservationEvent) GetEvent

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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