dynamic-resource-allocationk8s.io/dynamic-resource-allocation/resourceclaim Index | Files

package resourceclaim

import "k8s.io/dynamic-resource-allocation/resourceclaim"

Package resourceclaim provides code that supports the usual pattern for accessing the ResourceClaim that is referenced by a PodResourceClaim:

- determine the ResourceClaim name that corresponds to the PodResourceClaim - retrieve the ResourceClaim - verify that the ResourceClaim is owned by the pod if generated from a template - use the ResourceClaim

Index

Variables

var (
	// ErrAPIUnsupported is wrapped by the actual errors returned by Name and
	// indicates that none of the required fields are set.
	ErrAPIUnsupported = errors.New("none of the supported fields are set")

	// ErrClaimNotFound is wrapped by the actual errors returned by Name and
	// indicates that the claim has not been created yet.
	ErrClaimNotFound = errors.New("ResourceClaim not created yet")
)

Functions

func CanBeReserved

func CanBeReserved(claim *resourcev1alpha2.ResourceClaim) bool

CanBeReserved checks whether the claim could be reserved for another object.

func IsAllocatedWithStructuredParameters

func IsAllocatedWithStructuredParameters(claim *resourcev1alpha2.ResourceClaim) bool

IsAllocatedWithStructuredParameters checks whether the claim is allocated and the allocation was done with structured parameters.

func IsForPod

func IsForPod(pod *v1.Pod, claim *resourcev1alpha2.ResourceClaim) error

IsForPod checks that the ResourceClaim is the one that was created for the Pod. It returns an error that is informative enough to be returned by the caller without adding further details about the Pod or ResourceClaim.

func IsReservedForPod

func IsReservedForPod(pod *v1.Pod, claim *resourcev1alpha2.ResourceClaim) bool

IsReservedForPod checks whether a claim lists the pod as one of the objects that the claim was reserved for.

func Name

func Name(pod *v1.Pod, podClaim *v1.PodResourceClaim) (name *string, mustCheckOwner bool, err error)

Name returns the name of the ResourceClaim object that gets referenced by or created for the PodResourceClaim. Three different results are possible:

Determining the name depends on Kubernetes >= 1.28.

Types

type Lookup

type Lookup struct {
	// contains filtered or unexported fields
}

Lookup stores the state which is necessary to look up ResourceClaim names.

func NewNameLookup

func NewNameLookup(client kubernetes.Interface) *Lookup

NewNameLookup returns an object which handles determining the name of a ResourceClaim. In contrast to the stand-alone Name it is compatible also with Kubernetes < 1.28.

Providing a client is optional. If none is available, then code can pass nil and users can set the DRA_WITH_DETERMINISTIC_RESOURCE_CLAIM_NAMES env variable to an arbitrary non-empty value to use the naming from Kubernetes < 1.28.

func (*Lookup) Name

func (l *Lookup) Name(pod *v1.Pod, podClaim *v1.PodResourceClaim) (name *string, mustCheckOwner bool, err error)

Name is a variant of the stand-alone Name with support also for Kubernetes < 1.28.

Source Files

resourceclaim.go

Version
v0.30.0-rc.1
Published
Apr 3, 2024
Platform
js/wasm
Imports
10 packages
Last checked
5 minutes ago

Tools for package owners.