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
- func BaseRequestRef(requestRef string) string
- func CanBeReserved(claim *resourceapi.ResourceClaim) bool
- func ConfigForResult(deviceConfigurations []resourceapi.DeviceAllocationConfiguration, result resourceapi.DeviceRequestAllocationResult) []resourceapi.DeviceAllocationConfiguration
- func IsForPod(pod *v1.Pod, claim *resourceapi.ResourceClaim) error
- func IsReservedForPod(pod *v1.Pod, claim *resourceapi.ResourceClaim) bool
- func Name(pod *v1.Pod, podClaim *v1.PodResourceClaim) (name *string, mustCheckOwner bool, err error)
- func PodStatusEqual(statusA, statusB []corev1.PodResourceClaimStatus) bool
- func ToleratesTaint(toleration resourceapi.DeviceToleration, taint resourceapi.DeviceTaint) bool
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 BaseRequestRef ¶
BaseRequestRef returns the request name if the reference is to a top-level request and the name of the parent request if the reference is to a subrequest.
func CanBeReserved ¶
func CanBeReserved(claim *resourceapi.ResourceClaim) bool
CanBeReserved checks whether the claim could be reserved for another object.
func ConfigForResult ¶
func ConfigForResult(deviceConfigurations []resourceapi.DeviceAllocationConfiguration, result resourceapi.DeviceRequestAllocationResult) []resourceapi.DeviceAllocationConfiguration
ConfigForResult returns the configs that are applicable to device allocated for the provided result.
func IsForPod ¶
func IsForPod(pod *v1.Pod, claim *resourceapi.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 *resourceapi.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:
An error is returned when some field is not set as expected (either the input is invalid or the API got extended and the library and the client using it need to be updated) or the claim hasn't been created yet.
The error includes pod and pod claim name and the unexpected field and is derived from one of the pre-defined errors in this package.
A nil string pointer and no error when the ResourceClaim intentionally didn't get created and the PodResourceClaim can be ignored.
A pointer to the name and no error when the ResourceClaim got created. In this case the boolean determines whether IsForPod must be called after retrieving the ResourceClaim and before using it.
Determining the name depends on Kubernetes >= 1.28.
func PodStatusEqual ¶
func PodStatusEqual(statusA, statusB []corev1.PodResourceClaimStatus) bool
PodStatusEqual checks that both slices have the same number of entries and that the pairs of entries are semantically equivalent.
The order of the entries matters: two slices with semantically equivalent entries in different order are not equal. This is done for the sake of performance because typically the order of entries doesn't change.
func ToleratesTaint ¶
func ToleratesTaint(toleration resourceapi.DeviceToleration, taint resourceapi.DeviceTaint) bool
ToleratesTaint checks if the toleration tolerates the taint. The matching follows the rules below:
- Empty toleration.effect means to match all taint effects, otherwise taint effect must equal to toleration.effect.
- If toleration.operator is 'Exists', it means to match all taint values.
- Empty toleration.key means to match all taint keys. If toleration.key is empty, toleration.operator must be 'Exists'; this combination means to match all taint values and all taint keys.
Source Files ¶
devicetoleration.go pod.go resourceclaim.go
- Version
- v0.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 1 day ago –
Tools for package owners.