quotaevaluate

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQuotaAdmission

func GetQuotaAdmission(quota *v1alpha1.ElasticQuota) (corev1.ResourceList, error)

func IsDefaultDeny

func IsDefaultDeny(err error) bool

IsDefaultDeny returns true if the error is defaultDeny

func NewQuotaAccessor

func NewQuotaAccessor(c client.Client) *quotaAccessor

NewQuotaAccessor creates an object that conforms to the QuotaAccessor interface to be used to retrieve quota objects.

func PodUsageFunc

func PodUsageFunc(pod *corev1.Pod, clock clock.Clock) (corev1.ResourceList, error)

func QuotaV1Pod

func QuotaV1Pod(pod *corev1.Pod, clock clock.Clock) bool

Types

type Attributes

type Attributes struct {
	QuotaNamespace string
	QuotaName      string
	Operation      admissionv1.Operation
	Pod            *corev1.Pod
}

type Evaluator

type Evaluator interface {
	// Evaluate takes an operation and checks to see if quota constraints are satisfied.  It returns an error if they are not.
	// The default implementation processes related operations in chunks when possible.
	Evaluate(a *Attributes) error
}

Evaluator is used to see if quota constraints are satisfied.

func NewQuotaEvaluator

func NewQuotaEvaluator(quotaAccessor QuotaAccessor, workers int, stopCh <-chan struct{}) Evaluator

type QuotaAccessor

type QuotaAccessor interface {
	// UpdateQuotaStatus is called to persist final status.  This method should write to persistent storage.
	// An error indicates that write didn't complete successfully.
	UpdateQuotaStatus(newQuota *v1alpha1.ElasticQuota) error

	// GetQuota gets the specificated elastic quota.
	GetQuota(key string) (*v1alpha1.ElasticQuota, error)
}

QuotaAccessor abstracts the get/set logic from the rest of the Evaluator. This could be a test stub, a straight passthrough, or most commonly a series of deconflicting caches.

Jump to

Keyboard shortcuts

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