api

package
v0.0.0-...-fb4d9db Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

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

Variables

This section is empty.

Functions

func AllocatedStatus

func AllocatedStatus(status TaskStatus) bool

func JobTerminated

func JobTerminated(job *JobInfo) bool

JobTerminated checks whether job was terminated.

func MergeErrors

func MergeErrors(errs ...error) error

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

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          *v1alpha1.PodGroup

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

	// Custom properties
	ID           int
	Trace        string
	Type         string
	FastDuration int
	SlowDuration int
	CreationTime metav1.Time
}

func NewJobInfo

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

func (*JobInfo) AddTaskInfo

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

func (*JobInfo) Clone

func (ji *JobInfo) Clone() *JobInfo

func (*JobInfo) DeleteTaskInfo

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

func (*JobInfo) FitError

func (ji *JobInfo) FitError() string

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 (ji *JobInfo) SetPodGroup(pg *v1alpha1.PodGroup)

func (JobInfo) String

func (ji JobInfo) String() string

func (*JobInfo) UnsetPDB

func (ji *JobInfo) UnsetPDB()

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

	// Custom properties
	ID   int
	Rack int
	GPU  bool
}

NodeInfo is node level aggregated information.

func NewNodeInfo

func NewNodeInfo(node *v1.Node) *NodeInfo

func (*NodeInfo) AddTask

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

func (*NodeInfo) Clone

func (ni *NodeInfo) Clone() *NodeInfo

func (*NodeInfo) Pods

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

func (*NodeInfo) RemoveTask

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

func (*NodeInfo) SetNode

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

func (NodeInfo) String

func (ni NodeInfo) String() string

func (*NodeInfo) UpdateTask

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

type NodeOrderFn

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

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

type NodeResourceMap

type NodeResourceMap map[string]*Resource

type PredicateFn

type PredicateFn func(*TaskInfo, *NodeInfo) error

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

type QueueID

type QueueID types.UID

type QueueInfo

type QueueInfo struct {
	UID  QueueID
	Name string

	Weight int32

	Queue *arbcorev1.Queue
}

func NewQueueInfo

func NewQueueInfo(queue *arbcorev1.Queue) *QueueInfo

func (*QueueInfo) Clone

func (q *QueueInfo) Clone() *QueueInfo

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

func GetPodResourceRequest(pod *v1.Pod) *Resource

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

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

func (*Resource) Add

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

func (*Resource) Clone

func (r *Resource) Clone() *Resource

func (*Resource) FitDelta

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

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

func (*Resource) IsEmpty

func (r *Resource) IsEmpty() bool

func (*Resource) IsZero

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

func (*Resource) Less

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

func (*Resource) LessEqual

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

func (*Resource) Multi

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

func (*Resource) SetMaxResource

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

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

func (*Resource) String

func (r *Resource) String() string

func (*Resource) Sub

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

Sub subtracts two Resource objects.

type TaskID

type TaskID types.UID

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
}

func NewTaskInfo

func NewTaskInfo(pod *v1.Pod) *TaskInfo

func (*TaskInfo) Clone

func (ti *TaskInfo) Clone() *TaskInfo

func (TaskInfo) String

func (ti TaskInfo) String() 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

type ValidateExFn func(interface{}) *ValidateResult

type ValidateFn

type ValidateFn func(interface{}) bool

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

type ValidateResult

type ValidateResult struct {
	Pass    bool
	Reason  string
	Message string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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