Documentation ¶
Overview ¶
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func AllocatedStatus(status TaskStatus) bool
- func JobTerminated(job *JobInfo) bool
- func MergeErrors(errs ...error) error
- func ResourceNames() []v1.ResourceName
- 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) SetPDB(pdb *policyv1.PodDisruptionBudget)
- func (ji *JobInfo) SetPodGroup(pg *v1alpha1.PodGroup)
- func (ji JobInfo) String() string
- func (ji *JobInfo) UnsetPDB()
- func (ji *JobInfo) UnsetPodGroup()
- func (ji *JobInfo) UpdateTaskStatus(task *TaskInfo, status TaskStatus) error
- 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) 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 NodeResourceMap
- type PredicateFn
- type QueueID
- type QueueInfo
- type Resource
- func (r *Resource) Add(rr *Resource) *Resource
- func (r *Resource) Clone() *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) SetMaxResource(rr *Resource)
- 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 (
// 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
func JobTerminated ¶
JobTerminated checks whether job was terminated.
func MergeErrors ¶
func ResourceNames ¶
func ResourceNames() []v1.ResourceName
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 *v1alpha1.PodGroup // TODO(k82cn): keep backward compatibility, removed it when v1alpha1 finalized. PDB *policyv1.PodDisruptionBudget }
func NewJobInfo ¶
func (*JobInfo) AddTaskInfo ¶
func (*JobInfo) DeleteTaskInfo ¶
func (*JobInfo) FitError ¶ added in v0.4.1
Error 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
func (*JobInfo) SetPDB ¶
func (ji *JobInfo) SetPDB(pdb *policyv1.PodDisruptionBudget)
func (*JobInfo) SetPodGroup ¶
func (*JobInfo) UnsetPodGroup ¶
func (ji *JobInfo) UnsetPodGroup()
func (*JobInfo) UpdateTaskStatus ¶
func (ji *JobInfo) UpdateTaskStatus(task *TaskInfo, status TaskStatus) error
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 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 (*NodeInfo) RemoveTask ¶
func (*NodeInfo) UpdateTask ¶
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
type PredicateFn ¶
PredicateFn is the func declaration used to predicate node for task.
type QueueInfo ¶
func NewQueueInfo ¶
type Resource ¶
type Resource struct { MilliCPU float64 Memory float64 MilliGPU float64 // MaxTaskNum is only used by predicates; it should NOT // be accounted in other operators, e.g. Add. MaxTaskNum int }
func EmptyResource ¶
func EmptyResource() *Resource
func GetPodResourceRequest ¶ added in v0.4.2
Refer k8s.io/kubernetes/pkg/scheduler/algorithm/predicates/predicates.go#GetResourceRequest.
GetResourceRequest returns a *Resource that covers the largest width in each resource dimension. Because init-containers run sequentially, we collect the max in each dimension iteratively. In contrast, we sum the resource vectors for regular containers since they run simultaneously.
To be consistent with kubernetes default scheduler, it is only used for predicates of actions(e.g. allocate, backfill, preempt, reclaim), please use GetPodResourceWithoutInitContainers for other cases.
Example:
Pod:
InitContainers IC1: CPU: 2 Memory: 1G IC2: CPU: 2 Memory: 3G Containers C1: CPU: 2 Memory: 1G C2: CPU: 1 Memory: 1G
Result: CPU: 3, Memory: 3G
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
func (*Resource) FitDelta ¶ added in v0.4.1
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) SetMaxResource ¶ added in v0.4.2
SetMaxResource compares with ResourceList and takes max value for each 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 }
func NewTaskInfo ¶
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
type ValidateFn ¶
type ValidateFn func(interface{}) bool
ValidateFn is the func declaration used to check object's status.