resourcequota

package
v1.29.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 27 Imported by: 234

Documentation

Overview

Package resourcequota contains a controller that makes resource quota usage observations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQuotableResources added in v1.9.0

func GetQuotableResources(discoveryFunc NamespacedResourcesFunc) (map[schema.GroupVersionResource]struct{}, error)

GetQuotableResources returns all resources that the quota system should recognize. It requires a resource supports the following verbs: 'create','list','delete' This function may return both results and an error. If that happens, it means that the discovery calls were only partially successful. A decision about whether to proceed or not is left to the caller.

Types

type Controller added in v1.20.0

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

Controller is responsible for tracking quota usage status in the system

func NewController added in v1.20.0

func NewController(ctx context.Context, options *ControllerOptions) (*Controller, error)

NewController creates a quota controller with specified options

func (*Controller) Run added in v1.20.0

func (rq *Controller) Run(ctx context.Context, workers int)

Run begins quota controller using the specified number of workers

func (*Controller) Sync added in v1.20.0

func (rq *Controller) Sync(ctx context.Context, discoveryFunc NamespacedResourcesFunc, period time.Duration)

Sync periodically resyncs the controller when new resources are observed from discovery.

type ControllerOptions added in v1.20.0

type ControllerOptions struct {
	// Must have authority to list all quotas, and update quota status
	QuotaClient corev1client.ResourceQuotasGetter
	// Shared informer for resource quotas
	ResourceQuotaInformer coreinformers.ResourceQuotaInformer
	// Controls full recalculation of quota usage
	ResyncPeriod controller.ResyncPeriodFunc
	// Maintains evaluators that know how to calculate usage for group resource
	Registry quota.Registry
	// Discover list of supported resources on the server.
	DiscoveryFunc NamespacedResourcesFunc
	// A function that returns the list of resources to ignore
	IgnoredResourcesFunc func() map[schema.GroupResource]struct{}
	// InformersStarted knows if informers were started.
	InformersStarted <-chan struct{}
	// InformerFactory interfaces with informers.
	InformerFactory informerfactory.InformerFactory
	// Controls full resync of objects monitored for replenishment.
	ReplenishmentResyncPeriod controller.ResyncPeriodFunc
	// Filters update events so we only enqueue the ones where we know quota will change
	UpdateFilter UpdateFilter
}

ControllerOptions holds options for creating a quota controller

type NamespacedResourcesFunc added in v1.9.0

type NamespacedResourcesFunc func() ([]*metav1.APIResourceList, error)

NamespacedResourcesFunc knows how to discover namespaced resources.

type QuotaMonitor added in v1.9.0

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

QuotaMonitor contains all necessary information to track quotas and trigger replenishments

func NewMonitor added in v1.20.0

func NewMonitor(informersStarted <-chan struct{}, informerFactory informerfactory.InformerFactory, ignoredResources map[schema.GroupResource]struct{}, resyncPeriod controller.ResyncPeriodFunc, replenishmentFunc ReplenishmentFunc, registry quota.Registry, updateFilter UpdateFilter) *QuotaMonitor

NewMonitor creates a new instance of a QuotaMonitor

func (*QuotaMonitor) IsSynced added in v1.9.0

func (qm *QuotaMonitor) IsSynced(ctx context.Context) bool

IsSynced returns true if any monitors exist AND all those monitors' controllers HasSynced functions return true. This means IsSynced could return true at one time, and then later return false if all monitors were reconstructed.

func (*QuotaMonitor) Run added in v1.9.0

func (qm *QuotaMonitor) Run(ctx context.Context)

Run sets the stop channel and starts monitor execution until stopCh is closed. Any running monitors will be stopped before Run returns.

func (*QuotaMonitor) StartMonitors added in v1.10.0

func (qm *QuotaMonitor) StartMonitors(ctx context.Context)

StartMonitors ensures the current set of monitors are running. Any newly started monitors will also cause shared informers to be started.

If called before Run, StartMonitors does nothing (as there is no stop channel to support monitor/informer execution).

func (*QuotaMonitor) SyncMonitors added in v1.10.0

func (qm *QuotaMonitor) SyncMonitors(ctx context.Context, resources map[schema.GroupVersionResource]struct{}) error

SyncMonitors rebuilds the monitor set according to the supplied resources, creating or deleting monitors as necessary. It will return any error encountered, but will make an attempt to create a monitor for each resource instead of immediately exiting on an error. It may be called before or after Run. Monitors are NOT started as part of the sync. To ensure all existing monitors are started, call StartMonitors.

type ReplenishmentFunc added in v1.2.0

type ReplenishmentFunc func(ctx context.Context, groupResource schema.GroupResource, namespace string)

ReplenishmentFunc is a signal that a resource changed in specified namespace that may require quota to be recalculated.

type UpdateFilter added in v1.25.0

type UpdateFilter func(resource schema.GroupVersionResource, oldObj, newObj interface{}) bool

UpdateFilter is a function that returns true if the update event should be added to the resourceChanges queue.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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