utils

package
v0.0.0-...-e179f01 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPodReservationInPlace

func AddPodReservationInPlace(claim *resourceapi.ResourceClaim, pod *apiv1.Pod)

AddPodReservationInPlace adds a reservation for the provided pod to the provided Claim. It is a no-op if the claim is already reserved for the Pod.

func CalculateDynamicResourceUtilization

func CalculateDynamicResourceUtilization(nodeInfo *framework.NodeInfo) (map[string]map[string]float64, error)

CalculateDynamicResourceUtilization calculates a map of ResourceSlice pool utilization grouped by the driver and pool. Returns an error if the NodeInfo doesn't have all ResourceSlices from a pool.

func ClaimAllocated

func ClaimAllocated(claim *resourceapi.ResourceClaim) bool

ClaimAllocated returns whether the provided claim is allocated.

func ClaimAvailableOnNode

func ClaimAvailableOnNode(claim *resourceapi.ResourceClaim, node *apiv1.Node) (bool, error)

ClaimAvailableOnNode returns whether the provided claim is allocated and available on the provided Node.

func ClaimFullyReserved

func ClaimFullyReserved(claim *resourceapi.ResourceClaim) bool

ClaimFullyReserved returns whether the provided claim already has the maximum possible reservations set, and no more can be added.

func ClaimInUse

func ClaimInUse(claim *resourceapi.ResourceClaim) bool

ClaimInUse returns whether the provided claim is currently reserved for any consumer.

func ClaimOwningPod

func ClaimOwningPod(claim *resourceapi.ResourceClaim) (string, types.UID)

ClaimOwningPod returns the name and UID of the Pod owner of the provided claim. If the claim isn't owned by a Pod, empty strings are returned.

func ClaimReservedForPod

func ClaimReservedForPod(claim *resourceapi.ResourceClaim, pod *apiv1.Pod) bool

ClaimReservedForPod returns whether the provided claim is currently reserved for the provided pod.

func ClearPodReservationInPlace

func ClearPodReservationInPlace(claim *resourceapi.ResourceClaim, pod *apiv1.Pod)

ClearPodReservationInPlace clears the reservation for the provided pod in the provided Claim. It is a no-op if the claim isn't reserved for the Pod.

func DeallocateClaimInPlace

func DeallocateClaimInPlace(claim *resourceapi.ResourceClaim)

DeallocateClaimInPlace clears the allocation of the provided claim.

func HighestDynamicResourceUtilization

func HighestDynamicResourceUtilization(nodeInfo *framework.NodeInfo) (v1.ResourceName, float64, error)

HighestDynamicResourceUtilization returns the ResourceSlice driver and pool with the highest utilization.

func PodClaimConsumerReference

func PodClaimConsumerReference(pod *apiv1.Pod) resourceapi.ResourceClaimConsumerReference

PodClaimConsumerReference returns a consumer reference entry for a ResourceClaim status ReservedFor field.

func PodClaimOwnerReference

func PodClaimOwnerReference(pod *apiv1.Pod) metav1.OwnerReference

PodClaimOwnerReference returns an OwnerReference for a pod-owned ResourceClaim.

func SanitizedNodeResourceSlices

func SanitizedNodeResourceSlices(nodeLocalSlices []*resourceapi.ResourceSlice, newNodeName, nameSuffix string) (newSlices []*resourceapi.ResourceSlice, oldPoolNames set.Set[string], err error)

SanitizedNodeResourceSlices can be used to duplicate node-local ResourceSlices attached to a Node, when duplicating the Node. The new slices are pointed to newNodeName, and nameSuffix is appended to all pool names (pool names have to be unique within a driver, so we can't leave them as-is when duplicating). Returns a map of all pool names (without the suffix) that can be used with SanitizedPodResourceClaims(). Returns an error if any of the slices isn't node-local.

func SanitizedPodResourceClaims

func SanitizedPodResourceClaims(newOwner, oldOwner *v1.Pod, claims []*resourceapi.ResourceClaim, nameSuffix, newNodeName, oldNodeName string, oldNodePoolNames set.Set[string]) ([]*resourceapi.ResourceClaim, error)

SanitizedPodResourceClaims can be used to duplicate ResourceClaims needed by a Pod, when duplicating the Pod.

  • ResourceClaims owned by oldOwner are duplicated and sanitized, to be owned by a duplicate pod - newOwner.
  • ResourceClaims not owned by oldOwner are returned unchanged in the result. They are shared claims not bound to the lifecycle of the duplicated pod, so they shouldn't be duplicated.
  • Works for unallocated claims (e.g. if the pod being duplicated isn't scheduled).
  • Works for claims allocated on a single node that is being duplicated (e.g. if the pod being duplicated is a scheduled DS pod). The name of the old node and its pools have to be provided in this case. Such allocated claims are pointed to newNodeName, and nameSuffix is appended to all pool names in allocation results, to match the pool names of the new, duplicated node.
  • Returns an error if any of the allocated claims is not node-local on oldNodeName. Such allocations can't be sanitized, the only option is to clear the allocation and run scheduler filters&reserve to get a new allocation when duplicating a pod.

func SanitizedResourceClaimRefs

func SanitizedResourceClaimRefs(pod *v1.Pod, nameSuffix string) *v1.Pod

SanitizedResourceClaimRefs returns a duplicate of the provided pod, with nameSuffix appended to all pod-owned ResourceClaim names referenced in the Pod object. Names of ResourceClaims not owned by the pod are not changed.

func TestClaimWithAllocation

func TestClaimWithAllocation(claim *resourceapi.ResourceClaim, allocation *resourceapi.AllocationResult) *resourceapi.ResourceClaim

TestClaimWithAllocation returns a copy of the provided claim with an allocation set.

func TestClaimWithPodOwnership

func TestClaimWithPodOwnership(pod *apiv1.Pod, claim *resourceapi.ResourceClaim) *resourceapi.ResourceClaim

TestClaimWithPodOwnership returns a copy of the provided claim with OwnerReferences set up so that the claim is owned by the provided pod.

func TestClaimWithPodReservations

func TestClaimWithPodReservations(claim *resourceapi.ResourceClaim, pods ...*apiv1.Pod) *resourceapi.ResourceClaim

TestClaimWithPodReservations returns a copy of the provided claim with reservations for the provided pods added to ReservedFor.

Types

This section is empty.

Jump to

Keyboard shortcuts

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