api

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: Apache-2.0 Imports: 17 Imported by: 34

Documentation

Index

Constants

View Source
const (
	//PodGroupVersionV1Alpha1 represents PodGroupVersion of V1Alpha1
	PodGroupVersionV1Alpha1 string = "v1alpha1"

	//PodGroupVersionV1Alpha2 represents PodGroupVersion of V1Alpha2
	PodGroupVersionV1Alpha2 string = "v1alpha2"
	// PodPending means the pod group has been accepted by the system, but scheduler can not allocate
	// enough resources to it.
	PodGroupPending PodGroupPhase = "Pending"

	// PodRunning means `spec.minMember` pods of PodGroups has been in running phase.
	PodGroupRunning PodGroupPhase = "Running"

	// PodGroupUnknown means part of `spec.minMember` pods are running but the other part can not
	// be scheduled, e.g. not enough resource; scheduler will wait for related controller to recover it.
	PodGroupUnknown PodGroupPhase = "Unknown"
)

These are the valid phase of podGroups.

View Source
const (
	//QueueVersionV1Alpha1 represents PodGroupVersion of V1Alpha1
	QueueVersionV1Alpha1 string = "v1alpha1"

	//QueueVersionV1Alpha2 represents PodGroupVersion of V1Alpha2
	QueueVersionV1Alpha2 string = "v1alpha2"
)
View Source
const (
	// GPUResourceName need to follow https://github.com/NVIDIA/k8s-device-plugin/blob/66a35b71ac4b5cbfb04714678b548bd77e5ba719/server.go#L20
	GPUResourceName = "nvidia.com/gpu"
)

Variables

This section is empty.

Functions

func AllocatedStatus

func AllocatedStatus(status TaskStatus) bool

AllocatedStatus checks whether the tasks has AllocatedStatus

func ConvertPodGroupInfoToV1Alpha added in v0.5.0

func ConvertPodGroupInfoToV1Alpha(pg *PodGroup) (*v1alpha1.PodGroup, error)

ConvertPodGroupInfoToV1Alpha converts api.PodGroup type to v1alpha1.PodGroup

func ConvertPodGroupInfoToV2Alpha added in v0.5.0

func ConvertPodGroupInfoToV2Alpha(pg *PodGroup) (*v1alpha2.PodGroup, error)

ConvertPodGroupInfoToV2Alpha converts api.PodGroup type to v1alpha2.PodGroup

func JobTerminated

func JobTerminated(job *JobInfo) bool

JobTerminated checks whether job was terminated.

func MergeErrors

func MergeErrors(errs ...error) error

MergeErrors is used to merge multiple errors into single error

Types

type ClusterInfo

type ClusterInfo struct {
	Jobs   map[JobID]*JobInfo
	Nodes  map[string]*NodeInfo
	Queues map[QueueID]*QueueInfo
}

ClusterInfo is a snapshot of cluster by cache.

func (ClusterInfo) String

func (ci ClusterInfo) String() string

type CompareFn

type CompareFn func(interface{}, interface{}) int

CompareFn is the func declaration used by sort or priority queue.

type EvictableFn added in v0.4.1

type EvictableFn func(*TaskInfo, []*TaskInfo) []*TaskInfo

EvictableFn is the func declaration used to evict tasks.

type JobID

type JobID types.UID

JobID is the type of JobInfo's ID.

type JobInfo

type JobInfo struct {
	UID JobID

	Name      string
	Namespace string

	Queue QueueID

	Priority int32

	NodeSelector map[string]string
	MinAvailable int32

	NodesFitDelta NodeResourceMap

	// All tasks of the Job.
	TaskStatusIndex map[TaskStatus]tasksMap
	Tasks           tasksMap

	Allocated    *Resource
	TotalRequest *Resource

	CreationTimestamp metav1.Time
	PodGroup          *PodGroup

	// TODO(k82cn): keep backward compatibility, removed it when v1alpha1 finalized.
	PDB *policyv1.PodDisruptionBudget
}

JobInfo will have all info of a Job

func NewJobInfo

func NewJobInfo(uid JobID, tasks ...*TaskInfo) *JobInfo

NewJobInfo creates a new jobInfo for set of tasks

func (*JobInfo) AddTaskInfo

func (ji *JobInfo) AddTaskInfo(ti *TaskInfo)

AddTaskInfo is used to add a task to a job

func (*JobInfo) Clone

func (ji *JobInfo) Clone() *JobInfo

Clone is used to clone a jobInfo object

func (*JobInfo) DeleteTaskInfo

func (ji *JobInfo) DeleteTaskInfo(ti *TaskInfo) error

DeleteTaskInfo is used to delete a task from a job

func (*JobInfo) FitError added in v0.4.1

func (ji *JobInfo) FitError() string

FitError returns detailed information on why a job's task failed to fit on each available node

func (*JobInfo) GetTasks

func (ji *JobInfo) GetTasks(statuses ...TaskStatus) []*TaskInfo

GetTasks gets all tasks with the taskStatus

func (*JobInfo) Pipelined added in v0.5.0

func (ji *JobInfo) Pipelined() bool

Pipelined returns whether the number of ready and pipelined task is enough

func (*JobInfo) Ready added in v0.5.0

func (ji *JobInfo) Ready() bool

Ready returns whether job is ready for run

func (*JobInfo) ReadyTaskNum added in v0.5.0

func (ji *JobInfo) ReadyTaskNum() int32

ReadyTaskNum returns the number of tasks that are ready.

func (*JobInfo) SetPDB

func (ji *JobInfo) SetPDB(pdb *policyv1.PodDisruptionBudget)

SetPDB sets PDB to a job

func (*JobInfo) SetPodGroup

func (ji *JobInfo) SetPodGroup(pg *PodGroup)

SetPodGroup sets podGroup details to a job

func (JobInfo) String

func (ji JobInfo) String() string

String returns a jobInfo object in string format

func (*JobInfo) UnsetPDB

func (ji *JobInfo) UnsetPDB()

UnsetPDB removes PDB info of a job

func (*JobInfo) UnsetPodGroup

func (ji *JobInfo) UnsetPodGroup()

UnsetPodGroup removes podGroup details from a job

func (*JobInfo) UpdateTaskStatus

func (ji *JobInfo) UpdateTaskStatus(task *TaskInfo, status TaskStatus) error

UpdateTaskStatus is used to update task's status in a job

func (*JobInfo) ValidTaskNum added in v0.5.0

func (ji *JobInfo) ValidTaskNum() int32

ValidTaskNum returns the number of tasks that are valid.

func (*JobInfo) WaitingTaskNum added in v0.5.0

func (ji *JobInfo) WaitingTaskNum() int32

WaitingTaskNum returns the number of tasks that are pipelined.

type LessFn

type LessFn func(interface{}, interface{}) bool

LessFn is the func declaration used by sort or priority queue.

type NodeInfo

type NodeInfo struct {
	Name string
	Node *v1.Node

	// The state of node
	State NodeState

	// The releasing resource on that node
	Releasing *Resource
	// The idle resource on that node
	Idle *Resource
	// The used resource on that node, including running and terminating
	// pods
	Used *Resource

	Allocatable *Resource
	Capability  *Resource

	Tasks map[TaskID]*TaskInfo
}

NodeInfo is node level aggregated information.

func NewNodeInfo

func NewNodeInfo(node *v1.Node) *NodeInfo

NewNodeInfo is used to create new nodeInfo object

func (*NodeInfo) AddTask

func (ni *NodeInfo) AddTask(task *TaskInfo) error

AddTask is used to add a task in nodeInfo object

func (*NodeInfo) Clone

func (ni *NodeInfo) Clone() *NodeInfo

Clone used to clone nodeInfo Object

func (*NodeInfo) Pods

func (ni *NodeInfo) Pods() (pods []*v1.Pod)

Pods returns all pods running in that node

func (*NodeInfo) Ready added in v0.5.0

func (ni *NodeInfo) Ready() bool

Ready returns whether node is ready for scheduling

func (*NodeInfo) RemoveTask

func (ni *NodeInfo) RemoveTask(ti *TaskInfo) error

RemoveTask used to remove a task from nodeInfo object

func (*NodeInfo) SetNode

func (ni *NodeInfo) SetNode(node *v1.Node)

SetNode sets kubernetes node object to nodeInfo object

func (NodeInfo) String

func (ni NodeInfo) String() string

String returns nodeInfo details in string format

func (*NodeInfo) UpdateTask

func (ni *NodeInfo) UpdateTask(ti *TaskInfo) error

UpdateTask is used to update a task in nodeInfo object

type NodeOrderFn added in v0.4.1

type NodeOrderFn func(*TaskInfo, *NodeInfo) (float64, error)

NodeOrderFn is the func declaration used to get priority score for a node for a particular task.

type NodePhase added in v0.5.0

type NodePhase int

NodePhase defines the phase of node

const (
	// Ready means the node is ready for scheduling
	Ready NodePhase = 1 << iota
	// NotReady means the node is not ready for scheduling
	NotReady
)

func (NodePhase) String added in v0.5.0

func (np NodePhase) String() string

type NodeResourceMap added in v0.4.1

type NodeResourceMap map[string]*Resource

NodeResourceMap stores resource in a node

type NodeState added in v0.5.0

type NodeState struct {
	Phase  NodePhase
	Reason string
}

NodeState defines the current state of node.

type PodGroup added in v0.5.0

type PodGroup struct {
	metav1.TypeMeta `json:",inline"`
	// Standard object's metadata.
	// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
	// +optional
	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

	// Specification of the desired behavior of the pod group.
	// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
	// +optional
	Spec PodGroupSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`

	// Status represents the current information about a pod group.
	// This data may not be up to date.
	// +optional
	Status PodGroupStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`

	//Version represents the version of PodGroup
	Version string
}

PodGroup is a collection of Pod; used for batch workload.

func ConvertV1Alpha1ToPodGroupInfo added in v0.5.0

func ConvertV1Alpha1ToPodGroupInfo(pg *v1alpha1.PodGroup) (*PodGroup, error)

ConvertV1Alpha1ToPodGroupInfo converts v1alpha1.PodGroup to api.PodGroup type

func ConvertV1Alpha2ToPodGroupInfo added in v0.5.0

func ConvertV1Alpha2ToPodGroupInfo(pg *v1alpha2.PodGroup) (*PodGroup, error)

ConvertV1Alpha2ToPodGroupInfo converts v1alpha2.PodGroup to api.PodGroup type

type PodGroupCondition added in v0.5.0

type PodGroupCondition struct {
	// Type is the type of the condition
	Type PodGroupConditionType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type"`

	// Status is the status of the condition.
	Status v1.ConditionStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`

	// The ID of condition transition.
	TransitionID string `json:"transitionID,omitempty" protobuf:"bytes,3,opt,name=transitionID"`

	// Last time the phase transitioned from another to current phase.
	// +optional
	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"`

	// Unique, one-word, CamelCase reason for the phase's last transition.
	// +optional
	Reason string `json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"`

	// Human-readable message indicating details about last transition.
	// +optional
	Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`
}

PodGroupCondition contains details for the current state of this pod group.

type PodGroupConditionType added in v0.5.0

type PodGroupConditionType string

PodGroupConditionType is of string type which represents podGroup Condition

const (
	//PodGroupUnschedulableType represents unschedulable podGroup condition
	PodGroupUnschedulableType PodGroupConditionType = "Unschedulable"
)

type PodGroupPhase added in v0.5.0

type PodGroupPhase string

PodGroupPhase is the phase of a pod group at the current time.

type PodGroupSpec added in v0.5.0

type PodGroupSpec struct {
	// MinMember defines the minimal number of members/tasks to run the pod group;
	// if there's not enough resources to start all tasks, the scheduler
	// will not start anyone.
	MinMember int32 `json:"minMember,omitempty" protobuf:"bytes,1,opt,name=minMember"`

	// Queue defines the queue to allocate resource for PodGroup; if queue does not exist,
	// the PodGroup will not be scheduled.
	Queue string `json:"queue,omitempty" protobuf:"bytes,2,opt,name=queue"`

	// If specified, indicates the PodGroup's priority. "system-node-critical" and
	// "system-cluster-critical" are two special keywords which indicate the
	// highest priorities with the former being the highest priority. Any other
	// name must be defined by creating a PriorityClass object with that name.
	// If not specified, the PodGroup priority will be default or zero if there is no
	// default.
	// +optional
	PriorityClassName string `json:"priorityClassName,omitempty" protobuf:"bytes,3,opt,name=priorityClassName"`
}

PodGroupSpec represents the template of a pod group.

type PodGroupStatus added in v0.5.0

type PodGroupStatus struct {
	// Current phase of PodGroup.
	Phase PodGroupPhase `json:"phase,omitempty" protobuf:"bytes,1,opt,name=phase"`

	// The conditions of PodGroup.
	// +optional
	Conditions []PodGroupCondition `json:"conditions,omitempty" protobuf:"bytes,2,opt,name=conditions"`

	// The number of actively running pods.
	// +optional
	Running int32 `json:"running,omitempty" protobuf:"bytes,3,opt,name=running"`

	// The number of pods which reached phase Succeeded.
	// +optional
	Succeeded int32 `json:"succeeded,omitempty" protobuf:"bytes,4,opt,name=succeeded"`

	// The number of pods which reached phase Failed.
	// +optional
	Failed int32 `json:"failed,omitempty" protobuf:"bytes,5,opt,name=failed"`
}

PodGroupStatus represents the current state of a pod group.

type PredicateFn

type PredicateFn func(*TaskInfo, *NodeInfo) error

PredicateFn is the func declaration used to predicate node for task.

type Queue added in v0.5.0

type Queue struct {
	metav1.TypeMeta `json:",inline"`
	// Standard object's metadata.
	// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
	// +optional
	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

	// Specification of the desired behavior of the queue.
	// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
	// +optional
	Spec QueueSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`

	// The status of queue.
	// +optional
	Status QueueStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`

	//Version is used to retrieve information about queue version
	Version string
}

Queue is a queue of PodGroup.

type QueueID

type QueueID types.UID

QueueID is UID type, serves as unique ID for each queue

type QueueInfo

type QueueInfo struct {
	UID  QueueID
	Name string

	Weight int32

	Queue *Queue
}

QueueInfo will have all details about queue

func NewQueueInfo

func NewQueueInfo(queue *Queue) *QueueInfo

NewQueueInfo creates new queueInfo object

func (*QueueInfo) Clone

func (q *QueueInfo) Clone() *QueueInfo

Clone is used to clone queueInfo object

type QueueSpec added in v0.5.0

type QueueSpec struct {
	Weight     int32           `json:"weight,omitempty" protobuf:"bytes,1,opt,name=weight"`
	Capability v1.ResourceList `json:"capability,omitempty" protobuf:"bytes,2,opt,name=capability"`
}

QueueSpec represents the template of Queue.

type QueueStatus added in v0.5.0

type QueueStatus struct {
	// The number of 'Unknonw' PodGroup in this queue.
	Unknown int32 `json:"unknown,omitempty" protobuf:"bytes,1,opt,name=unknown"`
	// The number of 'Pending' PodGroup in this queue.
	Pending int32 `json:"pending,omitempty" protobuf:"bytes,2,opt,name=pending"`
	// The number of 'Running' PodGroup in this queue.
	Running int32 `json:"running,omitempty" protobuf:"bytes,3,opt,name=running"`
}

QueueStatus represents the status of Queue.

type Resource

type Resource struct {
	MilliCPU float64
	Memory   float64

	// ScalarResources
	ScalarResources map[v1.ResourceName]float64

	// MaxTaskNum is only used by predicates; it should NOT
	// be accounted in other operators, e.g. Add.
	MaxTaskNum int
}

Resource struct defines all the resource type

func EmptyResource

func EmptyResource() *Resource

EmptyResource creates a empty resource object and returns

func GetPodResourceRequest added in v0.4.2

func GetPodResourceRequest(pod *v1.Pod) *Resource

GetPodResourceRequest returns all the resource required for that pod

func GetPodResourceWithoutInitContainers added in v0.4.2

func GetPodResourceWithoutInitContainers(pod *v1.Pod) *Resource

GetPodResourceWithoutInitContainers returns Pod's resource request, it does not contain init containers' resource request.

func NewResource

func NewResource(rl v1.ResourceList) *Resource

NewResource create a new resource object from resource list

func (*Resource) Add

func (r *Resource) Add(rr *Resource) *Resource

Add is used to add the two resources

func (*Resource) AddScalar added in v0.5.0

func (r *Resource) AddScalar(name v1.ResourceName, quantity float64)

AddScalar adds a resource by a scalar value of this resource.

func (*Resource) Clone

func (r *Resource) Clone() *Resource

Clone is used to clone a resource type

func (*Resource) Diff added in v0.5.0

func (r *Resource) Diff(rr *Resource) (*Resource, *Resource)

Diff calculate the difference between two resource

func (*Resource) FitDelta added in v0.4.1

func (r *Resource) FitDelta(rr *Resource) *Resource

FitDelta Computes the delta between a resource oject representing available resources an operand representing resources being requested. Any field that is less than 0 after the operation represents an insufficient resource.

func (*Resource) Get

func (r *Resource) Get(rn v1.ResourceName) float64

Get returns the resource value for that particular resource type

func (*Resource) IsEmpty

func (r *Resource) IsEmpty() bool

IsEmpty returns bool after checking any of resource is less than min possible value

func (*Resource) IsZero

func (r *Resource) IsZero(rn v1.ResourceName) bool

IsZero checks whether that resource is less than min possible value

func (*Resource) Less

func (r *Resource) Less(rr *Resource) bool

Less checks whether a resource is less than other

func (*Resource) LessEqual

func (r *Resource) LessEqual(rr *Resource) bool

LessEqual checks whether a resource is less than other resource

func (*Resource) Multi

func (r *Resource) Multi(ratio float64) *Resource

Multi multiples the resource with ratio provided

func (*Resource) ResourceNames added in v0.5.0

func (r *Resource) ResourceNames() []v1.ResourceName

ResourceNames returns all resource types

func (*Resource) SetMaxResource added in v0.4.2

func (r *Resource) SetMaxResource(rr *Resource)

SetMaxResource compares with ResourceList and takes max value for each Resource.

func (*Resource) SetScalar added in v0.5.0

func (r *Resource) SetScalar(name v1.ResourceName, quantity float64)

SetScalar sets a resource by a scalar value of this resource.

func (*Resource) String

func (r *Resource) String() string

String returns resource details in string format

func (*Resource) Sub

func (r *Resource) Sub(rr *Resource) *Resource

Sub subtracts two Resource objects.

type TaskID

type TaskID types.UID

TaskID is UID type for Task

func PodKey

func PodKey(pod *v1.Pod) TaskID

PodKey returns the string key of a pod.

type TaskInfo

type TaskInfo struct {
	UID TaskID
	Job JobID

	Name      string
	Namespace string

	// Resreq is the resource that used when task running.
	Resreq *Resource
	// InitResreq is the resource that used to launch a task.
	InitResreq *Resource

	NodeName    string
	Status      TaskStatus
	Priority    int32
	VolumeReady bool

	Pod *v1.Pod
}

TaskInfo will have all infos about the task

func NewTaskInfo

func NewTaskInfo(pod *v1.Pod) *TaskInfo

NewTaskInfo creates new taskInfo object for a Pod

func (*TaskInfo) Clone

func (ti *TaskInfo) Clone() *TaskInfo

Clone is used for cloning a task

func (TaskInfo) String

func (ti TaskInfo) String() string

String returns the taskInfo details in a string

type TaskStatus

type TaskStatus int

TaskStatus defines the status of a task/pod.

const (
	// Pending means the task is pending in the apiserver.
	Pending TaskStatus = 1 << iota

	// Allocated means the scheduler assigns a host to it.
	Allocated

	// Pipelined means the scheduler assigns a host to wait for releasing resource.
	Pipelined

	// Binding means the scheduler send Bind request to apiserver.
	Binding

	// Bound means the task/Pod bounds to a host.
	Bound

	// Running means a task is running on the host.
	Running

	// Releasing means a task/pod is deleted.
	Releasing

	// Succeeded means that all containers in the pod have voluntarily terminated
	// with a container exit code of 0, and the system is not going to restart any of these containers.
	Succeeded

	// Failed means that all containers in the pod have terminated, and at least one container has
	// terminated in a failure (exited with a non-zero exit code or was stopped by the system).
	Failed

	// Unknown means the status of task/pod is unknown to the scheduler.
	Unknown
)

func (TaskStatus) String

func (ts TaskStatus) String() string

type ValidateExFn added in v0.4.1

type ValidateExFn func(interface{}) *ValidateResult

ValidateExFn is the func declaration used to validate the result

type ValidateFn

type ValidateFn func(interface{}) bool

ValidateFn is the func declaration used to check object's status.

type ValidateResult added in v0.4.1

type ValidateResult struct {
	Pass    bool
	Reason  string
	Message string
}

ValidateResult is struct to which can used to determine the result

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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