Documentation ¶
Index ¶
- Variables
- func Age(pod *k8sCore.Pod, now time.Time) time.Duration
- func AsPodReferenceList(podList *k8sCore.PodList) []*k8sCore.Pod
- func ButPodAnnotation(pod *k8sCore.Pod, key string, value string) *k8sCore.Pod
- func ButPodAssignedToNode(pod *k8sCore.Pod, node *k8sCore.Node) *k8sCore.Pod
- func ButPodCapacityGroup(pod *k8sCore.Pod, capacityGroup string) *k8sCore.Pod
- func ButPodLabel(pod *k8sCore.Pod, key string, value string) *k8sCore.Pod
- func ButPodMachineRequiredAffinity(pod *k8sCore.Pod, machineTypes []string) *k8sCore.Pod
- func ButPodName(pod *k8sCore.Pod, name string) *k8sCore.Pod
- func ButPodResourcePools(pod *k8sCore.Pod, resourcePools ...string) *k8sCore.Pod
- func ButPodResources(pod *k8sCore.Pod, resource poolApi.ComputeResource) *k8sCore.Pod
- func ButPodRunningOnNode(pod *k8sCore.Pod, node *k8sCore.Node) *k8sCore.Pod
- func CountNotScheduledPods(pods []*k8sCore.Pod) int64
- func FilterPodsOkWithMachineTypes(pods []*k8sCore.Pod, machineTypes []string) []*k8sCore.Pod
- func FilterRunningPods(pods []*k8sCore.Pod) []*k8sCore.Pod
- func FindNotScheduledPods(pods []*k8sCore.Pod) []*k8sCore.Pod
- func FindOldNotScheduledPods(pods []*k8sCore.Pod, youngPodThreshold time.Duration, now time.Time) []*k8sCore.Pod
- func FindPodAssignedResourcePools(pod *k8sCore.Pod) ([]string, bool)
- func FindPodCapacityGroup(pod *k8sCore.Pod) string
- func FindPodPrimaryResourcePool(pod *k8sCore.Pod) (string, bool)
- func FindPodsWithPrimaryResourcePool(resourcePool string, pods []*k8sCore.Pod) []*k8sCore.Pod
- func FormatPod(pod *v1.Pod, options poolUtil.FormatterOptions) string
- func FromPodToComputeResource(pod *k8sCore.Pod) poolApi.ComputeResource
- func GetApplicationName(pod *k8sCore.Pod, defaultValue string) string
- func GetJobType(pod *k8sCore.Pod, defaultValue string) string
- func GetPodRequestedMachineTypes(pod *k8sCore.Pod) []string
- func GetPreemptedPodIds(pod *k8sCore.Pod) []string
- func GetPreemptedPodsCount(pod *k8sCore.Pod) int64
- func GetScheduledTroughName(pod *k8sCore.Pod) (string, error)
- func IsPodFinished(pod *k8sCore.Pod) bool
- func IsPodInCapacityGroup(pod *k8sCore.Pod, cg *v1.CapacityGroup) bool
- func IsPodInPrimaryResourcePool(resourcePool string, pod *k8sCore.Pod) bool
- func IsPodOkWithMachineTypesSet(pod *k8sCore.Pod, machineTypes map[string]bool) bool
- func IsPodPreemptible(pod *k8sCore.Pod) bool
- func IsPodRunning(pod *k8sCore.Pod) bool
- func IsPodWaitingToBeScheduled(pod *k8sCore.Pod) bool
- func Names(pods *[]k8sCore.Pod) []string
- func NewNotScheduledPod(resourcePoolName string, resources poolApi.ComputeResource, now time.Time) *coreV1.Pod
- func NewNotScheduledPodWithName(name string, resourcePoolName string, resources poolApi.ComputeResource, ...) *coreV1.Pod
- func NewNotScheduledPods(count int64, namePrefix string, resourcePoolName string, ...) []*coreV1.Pod
- func NewRandomNotScheduledPod() *coreV1.Pod
- func PodBelongsToResourcePool(pod *k8sCore.Pod, assignedPools []string, resourcePool string, ...) bool
- func SumPodResources(pods []*k8sCore.Pod) poolApi.ComputeResource
- type Metadata
- type Options
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
var ( EmptyPod = func() *k8sCore.Pod { return &k8sCore.Pod{ ObjectMeta: metaV1.ObjectMeta{ Name: "emptyPod", }, } } )
We use functions, as K8S records are mutable
Functions ¶
func ButPodAnnotation ¶ added in v0.8.0
func ButPodAssignedToNode ¶ added in v0.8.0
func ButPodCapacityGroup ¶ added in v0.8.0
func ButPodLabel ¶ added in v0.8.0
func ButPodResourcePools ¶ added in v0.8.0
func ButPodResources ¶ added in v0.9.0
func ButPodRunningOnNode ¶ added in v0.8.0
func CountNotScheduledPods ¶ added in v0.8.0
func FilterPodsOkWithMachineTypes ¶
See IsPodOkWithMachineTypes to understand the filtering criteria.
func FindNotScheduledPods ¶ added in v0.8.0
func FindOldNotScheduledPods ¶ added in v0.8.0
func FindOldNotScheduledPods(pods []*k8sCore.Pod, youngPodThreshold time.Duration, now time.Time) []*k8sCore.Pod
Find all unscheduled pods belonging to the given resource pool, which are not younger than a threshold.
func FindPodAssignedResourcePools ¶ added in v0.13.0
A pod may be assigned to multiple resource pools. The first one returned is considered the primary which will be scaled up if more capacity is needed.
func FindPodCapacityGroup ¶ added in v0.7.0
func FindPodPrimaryResourcePool ¶ added in v0.13.0
func FindPodsWithPrimaryResourcePool ¶ added in v0.13.0
Find all pods for which the given resource pool is primary.
func FormatPod ¶ added in v0.8.0
func FormatPod(pod *v1.Pod, options poolUtil.FormatterOptions) string
func FromPodToComputeResource ¶ added in v0.8.0
func FromPodToComputeResource(pod *k8sCore.Pod) poolApi.ComputeResource
func GetApplicationName ¶ added in v0.32.1
func GetPodRequestedMachineTypes ¶
Return machine types explicitly requested by pod using hard affinity rules.
func GetPreemptedPodIds ¶ added in v0.32.1
func GetPreemptedPodsCount ¶ added in v0.32.1
func GetScheduledTroughName ¶ added in v0.38.1
func IsPodFinished ¶ added in v0.8.0
func IsPodInCapacityGroup ¶ added in v0.7.0
func IsPodInCapacityGroup(pod *k8sCore.Pod, cg *v1.CapacityGroup) bool
func IsPodInPrimaryResourcePool ¶ added in v0.13.0
func IsPodOkWithMachineTypesSet ¶
Returns true if the given pod can be run on the provided machine types. If the machine types list is empty, returns false. Otherwise for a pod to not match, it must have a machine hard constraint with machine types disjoned with the provided set.
For example if machinesTypes=["r5.metal", "m5.metal"] and pod requires ["c5.metal], it will not be added to the result. If machinesTypes=["r5.metal", "m5.metal"] and pod requires ["r5.metal", "c5.metal], it will be added to the result.
func IsPodPreemptible ¶ added in v0.32.1
IsPodPreemptible checks if the pod's priority class is enabled for trough.
func IsPodRunning ¶ added in v0.8.0
func IsPodWaitingToBeScheduled ¶ added in v0.8.0
func NewNotScheduledPod ¶ added in v0.8.0
func NewNotScheduledPodWithName ¶ added in v0.8.0
func NewNotScheduledPods ¶ added in v0.8.0
func NewRandomNotScheduledPod ¶ added in v0.8.0
func PodBelongsToResourcePool ¶ added in v0.13.0
func PodBelongsToResourcePool(pod *k8sCore.Pod, assignedPools []string, resourcePool string, resourcePoolWithGpus bool, nodes map[string]*k8sCore.Node) bool
TODO remove
func SumPodResources ¶ added in v0.8.0
func SumPodResources(pods []*k8sCore.Pod) poolApi.ComputeResource
Types ¶
type Metadata ¶ added in v0.13.0
type Metadata struct { PrimaryResourcePool string AssignedResourcePools []string UsedResourcePool string PodResources v1.ComputeResource }
type Snapshot ¶ added in v0.13.0
type Snapshot struct { AllByName map[string]*k8sCore.Pod QueuedYoungByName map[string]*k8sCore.Pod QueuedOldByName map[string]*k8sCore.Pod ScheduledByName map[string]*k8sCore.Pod FinishedByName map[string]*k8sCore.Pod Metadata map[string]*Metadata // Pods with the primary resource pool being this one Primary map[string]*k8sCore.Pod }
Node data snapshot with useful indexes for fast access. Snapshot struct can be mutated by calling the provided functions (Add, Transform). Those updates are applied in place, so if a client keeps reference to a collection (for example AllByName), it may change as well. To support fast O(1) mutations, only map collections are provided.
func NewFilteredByNodeAllocation ¶ added in v0.13.0
func NewFilteredByNodeAllocation(unfilteredSnapshot *Snapshot, resourcePool string, nodeSnapshot *poolNode.Snapshot) (*Snapshot, []*k8sCore.Pod)
Given the unfilteredSnapshot, remove all pods in running state that run on nodes not owned by the given resource pool.
func NewSnapshotOfResourcePool ¶ added in v0.13.0
func NewSnapshotOfResourcePool(pods []*k8sCore.Pod, resourcePool string, options Options) (*Snapshot, []*k8sCore.Pod)
Returns Snapshot of pods associated with the given resource pool and the list of the remaining pods. This factory does not filter out running pods on node resources not belonging to this resource pool (expected if a pod is associated with many resource pools). This additional filtering step can be done by calling NewFilteredByNodeAllocation and passing the node data.