Documentation ¶
Index ¶
- Constants
- func AllocatedStatus(status TaskStatus) bool
- func ConvertPodGroupInfoToV1Alpha(pg *PodGroup) (*v1alpha1.PodGroup, error)
- func ConvertPodGroupInfoToV2Alpha(pg *PodGroup) (*v1alpha2.PodGroup, error)
- func JobTerminated(job *JobInfo) bool
- func MergeErrors(errs ...error) error
- type ClusterInfo
- type CompareFn
- type EvictableFn
- type JobID
- type JobInfo
- func (ji *JobInfo) AddTaskInfo(ti *TaskInfo)
- func (ji *JobInfo) Clone() *JobInfo
- func (ji *JobInfo) DeleteTaskInfo(ti *TaskInfo) error
- func (ji *JobInfo) FitError() string
- func (ji *JobInfo) GetTasks(statuses ...TaskStatus) []*TaskInfo
- func (ji *JobInfo) Pipelined() bool
- func (ji *JobInfo) Ready() bool
- func (ji *JobInfo) ReadyTaskNum() int32
- func (ji *JobInfo) SetPDB(pdb *policyv1.PodDisruptionBudget)
- func (ji *JobInfo) SetPodGroup(pg *PodGroup)
- func (ji JobInfo) String() string
- func (ji *JobInfo) UnsetPDB()
- func (ji *JobInfo) UnsetPodGroup()
- func (ji *JobInfo) UpdateTaskStatus(task *TaskInfo, status TaskStatus) error
- func (ji *JobInfo) ValidTaskNum() int32
- func (ji *JobInfo) WaitingTaskNum() int32
- type LessFn
- type NodeInfo
- func (ni *NodeInfo) AddTask(task *TaskInfo) error
- func (ni *NodeInfo) Clone() *NodeInfo
- func (ni *NodeInfo) Pods() (pods []*v1.Pod)
- func (ni *NodeInfo) Ready() bool
- func (ni *NodeInfo) RemoveTask(ti *TaskInfo) error
- func (ni *NodeInfo) SetNode(node *v1.Node)
- func (ni NodeInfo) String() string
- func (ni *NodeInfo) UpdateTask(ti *TaskInfo) error
- type NodeOrderFn
- type NodePhase
- type NodeResourceMap
- type NodeState
- type PodGroup
- type PodGroupCondition
- type PodGroupConditionType
- type PodGroupPhase
- type PodGroupSpec
- type PodGroupStatus
- type PredicateFn
- type Queue
- type QueueID
- type QueueInfo
- type QueueSpec
- type QueueStatus
- type Resource
- func (r *Resource) Add(rr *Resource) *Resource
- func (r *Resource) AddScalar(name v1.ResourceName, quantity float64)
- func (r *Resource) Clone() *Resource
- func (r *Resource) Diff(rr *Resource) (*Resource, *Resource)
- func (r *Resource) FitDelta(rr *Resource) *Resource
- func (r *Resource) Get(rn v1.ResourceName) float64
- func (r *Resource) IsEmpty() bool
- func (r *Resource) IsZero(rn v1.ResourceName) bool
- func (r *Resource) Less(rr *Resource) bool
- func (r *Resource) LessEqual(rr *Resource) bool
- func (r *Resource) Multi(ratio float64) *Resource
- func (r *Resource) ResourceNames() []v1.ResourceName
- func (r *Resource) SetMaxResource(rr *Resource)
- func (r *Resource) SetScalar(name v1.ResourceName, quantity float64)
- func (r *Resource) String() string
- func (r *Resource) Sub(rr *Resource) *Resource
- type TaskID
- type TaskInfo
- type TaskStatus
- type ValidateExFn
- type ValidateFn
- type ValidateResult
Constants ¶
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.
const ( //QueueVersionV1Alpha1 represents PodGroupVersion of V1Alpha1 QueueVersionV1Alpha1 string = "v1alpha1" //QueueVersionV1Alpha2 represents PodGroupVersion of V1Alpha2 QueueVersionV1Alpha2 string = "v1alpha2" )
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
ConvertPodGroupInfoToV1Alpha converts api.PodGroup type to v1alpha1.PodGroup
func ConvertPodGroupInfoToV2Alpha ¶ added in v0.5.0
ConvertPodGroupInfoToV2Alpha converts api.PodGroup type to v1alpha2.PodGroup
func JobTerminated ¶
JobTerminated checks whether job was terminated.
func MergeErrors ¶
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
EvictableFn is the func declaration used to evict tasks.
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 ¶
NewJobInfo creates a new jobInfo for set of tasks
func (*JobInfo) AddTaskInfo ¶
AddTaskInfo is used to add a task to a job
func (*JobInfo) DeleteTaskInfo ¶
DeleteTaskInfo is used to delete a task from a job
func (*JobInfo) FitError ¶ added in v0.4.1
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
Pipelined returns whether the number of ready and pipelined task is enough
func (*JobInfo) ReadyTaskNum ¶ added in v0.5.0
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 ¶
SetPodGroup sets podGroup details to 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
ValidTaskNum returns the number of tasks that are valid.
func (*JobInfo) WaitingTaskNum ¶ added in v0.5.0
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 ¶
NewNodeInfo is used to create new nodeInfo object
func (*NodeInfo) RemoveTask ¶
RemoveTask used to remove a task from nodeInfo object
func (*NodeInfo) UpdateTask ¶
UpdateTask is used to update a task in nodeInfo object
type NodeOrderFn ¶ added in v0.4.1
NodeOrderFn is the func declaration used to get priority score for a node for a particular task.
type NodeResourceMap ¶ added in v0.4.1
NodeResourceMap stores resource in a 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
ConvertV1Alpha1ToPodGroupInfo converts v1alpha1.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 ¶
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 QueueInfo ¶
QueueInfo will have all details about queue
func NewQueueInfo ¶
NewQueueInfo creates new 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
GetPodResourceRequest returns all the resource required for that pod
func GetPodResourceWithoutInitContainers ¶ added in v0.4.2
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) 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) FitDelta ¶ added in v0.4.1
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 ¶
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) 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
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.
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 ¶
NewTaskInfo creates new taskInfo object for a Pod
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
ValidateResult is struct to which can used to determine the result