interfaces

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddApplicationRequest

type AddApplicationRequest struct {
	Metadata ApplicationMetadata
}

type AddTaskRequest

type AddTaskRequest struct {
	Metadata TaskMetadata
}

type AppManager

type AppManager interface {
	// the name of this application service
	// this info is exposed to the scheduler so we know what kind of apps
	// the scheduler is able to supervise.
	Name() string

	// if the service needs to init any objects, this is the place
	// the initialization of the service must not start any of go routines,
	// this will be called before starting the service.
	ServiceInit() error

	// if the service has some internal stuff to run, this is the place to run them
	// usually if an application is defined as K8s CRD, the operator service needs
	// to watch on these CRD events. the CRD informers can be launched here.
	// some implementation may not need to implement this.
	Start() error

	// if there is some go routines running in start, properly stop them while
	// the stop() function is called.
	Stop()
}

a common interface for app management service an app management service monitors the lifecycle of applications, it is responsible for reporting application status to the scheduler, that helps the scheduler to manage the application lifecycle natively.

type ApplicationManagementProtocol

type ApplicationManagementProtocol interface {
	// returns app that already existed in the cache,
	// or nil, false if app with the given appID is not found
	GetApplication(appID string) ManagedApp

	// add app to the context, app manager needs to provide all
	// necessary app metadata through this call. If this a existing app
	// for recovery, the AddApplicationRequest#Recovery must be true.
	AddApplication(request *AddApplicationRequest) ManagedApp

	// remove application from the context
	// returns an error if for some reason the app cannot be removed,
	// e.g the given app is not found in current context.
	RemoveApplication(appID string) error

	// add task to the context, if add is successful,
	AddTask(request *AddTaskRequest) ManagedTask

	// remove task from the app
	// return an error if for some reason the task cannot be removed
	// e.g app that owns this task is not found in context.
	RemoveTask(appID, taskID string)

	// notify the context that an app is completed,
	// this will trigger some consequent operations for the given app
	NotifyApplicationComplete(appID string)

	// notify the context that an app has failed,
	// this will trigger some consequent operations for the given app
	NotifyApplicationFail(appID string)

	// notify the context that an task is completed,
	// this will trigger some consequent operations for a given task,
	// e.g release the allocations that assigned for this task.
	NotifyTaskComplete(appID, taskID string)
}

app management protocol defines all the APIs needed for app management, this is the protocol between scheduler cache and app management plugins

type ApplicationMetadata

type ApplicationMetadata struct {
	ApplicationID              string
	QueueName                  string
	User                       string
	Tags                       map[string]string
	TaskGroups                 []v1alpha1.TaskGroup
	OwnerReferences            []metav1.OwnerReference
	SchedulingPolicyParameters *SchedulingPolicyParameters
	CreationTime               int64
}

type ManagedApp

type ManagedApp interface {
	GetApplicationID() string
	GetTask(taskID string) (ManagedTask, error)
	GetApplicationState() string
	GetQueue() string
	GetUser() string
	SetState(state string)
	TriggerAppRecovery() error
}

type ManagedTask

type ManagedTask interface {
	GetTaskID() string
	GetTaskState() string
	GetTaskPod() *v1.Pod
}

type Recoverable

type Recoverable interface {
	// list applications returns all existing applications known to this app manager.
	ListApplications() (map[string]ApplicationMetadata, error)

	// this is called during recovery
	// for a given pod, return an allocation if found
	GetExistingAllocation(pod *v1.Pod) *si.Allocation
}

recoverable interface defines a certain type of app that can be recovered upon scheduler' restart each app manager needs to implement this interface in order to support fault recovery

why we need this? the scheduler is stateless, all states are maintained just in memory, so each time when scheduler restarts, it needs to recover apps and nodes states from scratch. nodes state will be taken care of by the scheduler itself, however for apps state recovery, the scheduler will need to call this function to collect existing app info, and then properly recover these applications before recovering nodes.

type SchedulingPolicyParameters

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

func NewSchedulingPolicyParameters

func NewSchedulingPolicyParameters(placeholderTimeout int64, gangSchedulingStyle string) *SchedulingPolicyParameters

func (*SchedulingPolicyParameters) GetGangSchedulingStyle

func (spp *SchedulingPolicyParameters) GetGangSchedulingStyle() string

func (*SchedulingPolicyParameters) GetPlaceholderTimeout

func (spp *SchedulingPolicyParameters) GetPlaceholderTimeout() int64

type TaskMetadata

type TaskMetadata struct {
	ApplicationID string
	TaskID        string
	Pod           *v1.Pod
	Placeholder   bool
	TaskGroupName string
}

Jump to

Keyboard shortcuts

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