pod

package
v0.38.4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyPod = func() *k8sCore.Pod {
		return &k8sCore.Pod{
			ObjectMeta: metaV1.ObjectMeta{
				Name: "emptyPod",
			},
		}
	}
)

We use functions, as K8S records are mutable

Functions

func Age added in v0.9.0

func Age(pod *k8sCore.Pod, now time.Time) time.Duration

func AsPodReferenceList

func AsPodReferenceList(podList *k8sCore.PodList) []*k8sCore.Pod

func ButPodAnnotation added in v0.8.0

func ButPodAnnotation(pod *k8sCore.Pod, key string, value string) *k8sCore.Pod

func ButPodAssignedToNode added in v0.8.0

func ButPodAssignedToNode(pod *k8sCore.Pod, node *k8sCore.Node) *k8sCore.Pod

func ButPodCapacityGroup added in v0.8.0

func ButPodCapacityGroup(pod *k8sCore.Pod, capacityGroup string) *k8sCore.Pod

func ButPodLabel added in v0.8.0

func ButPodLabel(pod *k8sCore.Pod, key string, value string) *k8sCore.Pod

func ButPodMachineRequiredAffinity

func ButPodMachineRequiredAffinity(pod *k8sCore.Pod, machineTypes []string) *k8sCore.Pod

func ButPodName

func ButPodName(pod *k8sCore.Pod, name string) *k8sCore.Pod

func ButPodResourcePools added in v0.8.0

func ButPodResourcePools(pod *k8sCore.Pod, resourcePools ...string) *k8sCore.Pod

func ButPodResources added in v0.9.0

func ButPodResources(pod *k8sCore.Pod, resource poolApi.ComputeResource) *k8sCore.Pod

func ButPodRunningOnNode added in v0.8.0

func ButPodRunningOnNode(pod *k8sCore.Pod, node *k8sCore.Node) *k8sCore.Pod

func CountNotScheduledPods added in v0.8.0

func CountNotScheduledPods(pods []*k8sCore.Pod) int64

func FilterPodsOkWithMachineTypes

func FilterPodsOkWithMachineTypes(pods []*k8sCore.Pod, machineTypes []string) []*k8sCore.Pod

See IsPodOkWithMachineTypes to understand the filtering criteria.

func FilterRunningPods added in v0.8.0

func FilterRunningPods(pods []*k8sCore.Pod) []*k8sCore.Pod

func FindNotScheduledPods added in v0.8.0

func FindNotScheduledPods(pods []*k8sCore.Pod) []*k8sCore.Pod

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

func FindPodAssignedResourcePools(pod *k8sCore.Pod) ([]string, bool)

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 FindPodCapacityGroup(pod *k8sCore.Pod) string

func FindPodPrimaryResourcePool added in v0.13.0

func FindPodPrimaryResourcePool(pod *k8sCore.Pod) (string, bool)

func FindPodsWithPrimaryResourcePool added in v0.13.0

func FindPodsWithPrimaryResourcePool(resourcePool string, pods []*k8sCore.Pod) []*k8sCore.Pod

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 GetApplicationName(pod *k8sCore.Pod, defaultValue string) string

func GetJobType added in v0.32.1

func GetJobType(pod *k8sCore.Pod, defaultValue string) string

func GetPodRequestedMachineTypes

func GetPodRequestedMachineTypes(pod *k8sCore.Pod) []string

Return machine types explicitly requested by pod using hard affinity rules.

func GetPreemptedPodIds added in v0.32.1

func GetPreemptedPodIds(pod *k8sCore.Pod) []string

func GetPreemptedPodsCount added in v0.32.1

func GetPreemptedPodsCount(pod *k8sCore.Pod) int64

func GetScheduledTroughName added in v0.38.1

func GetScheduledTroughName(pod *k8sCore.Pod) (string, error)

func IsPodFinished added in v0.8.0

func IsPodFinished(pod *k8sCore.Pod) bool

func IsPodInCapacityGroup added in v0.7.0

func IsPodInCapacityGroup(pod *k8sCore.Pod, cg *v1.CapacityGroup) bool

func IsPodInPrimaryResourcePool added in v0.13.0

func IsPodInPrimaryResourcePool(resourcePool string, pod *k8sCore.Pod) bool

func IsPodOkWithMachineTypesSet

func IsPodOkWithMachineTypesSet(pod *k8sCore.Pod, machineTypes map[string]bool) bool

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

func IsPodPreemptible(pod *k8sCore.Pod) bool

IsPodPreemptible checks if the pod's priority class is enabled for trough.

func IsPodRunning added in v0.8.0

func IsPodRunning(pod *k8sCore.Pod) bool

func IsPodWaitingToBeScheduled added in v0.8.0

func IsPodWaitingToBeScheduled(pod *k8sCore.Pod) bool

func Names added in v0.9.0

func Names(pods *[]k8sCore.Pod) []string

func NewNotScheduledPod added in v0.8.0

func NewNotScheduledPod(resourcePoolName string, resources poolApi.ComputeResource, now time.Time) *coreV1.Pod

func NewNotScheduledPodWithName added in v0.8.0

func NewNotScheduledPodWithName(name string, resourcePoolName string, resources poolApi.ComputeResource,
	now time.Time) *coreV1.Pod

func NewNotScheduledPods added in v0.8.0

func NewNotScheduledPods(count int64, namePrefix string, resourcePoolName string, resources poolApi.ComputeResource,
	now time.Time) []*coreV1.Pod

func NewRandomNotScheduledPod added in v0.8.0

func NewRandomNotScheduledPod() *coreV1.Pod

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 Options added in v0.13.0

type Options struct {
	SupportGPUs        bool
	PastYoungThreshold func(pod *k8sCore.Pod, now time.Time) bool
}

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 NewEmpty added in v0.13.0

func NewEmpty() *Snapshot

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.

func (*Snapshot) IsPodWaitingToBeScheduled added in v0.13.0

func (s *Snapshot) IsPodWaitingToBeScheduled(podName string) bool

Jump to

Keyboard shortcuts

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