cache

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdmissionCheck added in v0.5.0

type AdmissionCheck struct {
	Active bool
}

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Cache keeps track of the Workloads that got admitted through ClusterQueues.

func New

func New(client client.Client, opts ...Option) *Cache

func (*Cache) AddClusterQueue

func (c *Cache) AddClusterQueue(ctx context.Context, cq *kueue.ClusterQueue) error

func (*Cache) AddLocalQueue added in v0.2.0

func (c *Cache) AddLocalQueue(q *kueue.LocalQueue) error

func (*Cache) AddOrUpdateAdmissionCheck added in v0.5.0

func (c *Cache) AddOrUpdateAdmissionCheck(ac *kueue.AdmissionCheck) sets.Set[string]

func (*Cache) AddOrUpdateResourceFlavor

func (c *Cache) AddOrUpdateResourceFlavor(rf *kueue.ResourceFlavor) sets.Set[string]

func (*Cache) AddOrUpdateWorkload

func (c *Cache) AddOrUpdateWorkload(w *kueue.Workload) bool

func (*Cache) AssumeWorkload

func (c *Cache) AssumeWorkload(w *kueue.Workload) error

func (*Cache) CleanUpOnContext added in v0.3.0

func (c *Cache) CleanUpOnContext(ctx context.Context)

CleanUpOnContext tracks the context. When closed, it wakes routines waiting on the podsReady condition. It should be called before doing any calls to cache.WaitForPodsReady.

func (*Cache) ClusterQueueActive added in v0.2.0

func (c *Cache) ClusterQueueActive(name string) bool

func (*Cache) ClusterQueueEmpty added in v0.2.0

func (c *Cache) ClusterQueueEmpty(name string) bool

ClusterQueueEmpty indicates whether there's any active workload admitted by the provided clusterQueue. Return true if the clusterQueue doesn't exist.

func (*Cache) ClusterQueueReadiness added in v0.5.0

func (c *Cache) ClusterQueueReadiness(name string) (metav1.ConditionStatus, string, string)

func (*Cache) ClusterQueueTerminating added in v0.2.0

func (c *Cache) ClusterQueueTerminating(name string) bool

func (*Cache) ClusterQueuesUsingAdmissionCheck added in v0.5.0

func (c *Cache) ClusterQueuesUsingAdmissionCheck(ac string) []string

func (*Cache) ClusterQueuesUsingFlavor added in v0.3.0

func (c *Cache) ClusterQueuesUsingFlavor(flavor string) []string

func (*Cache) DeleteAdmissionCheck added in v0.5.0

func (c *Cache) DeleteAdmissionCheck(ac *kueue.AdmissionCheck) sets.Set[string]

func (*Cache) DeleteClusterQueue

func (c *Cache) DeleteClusterQueue(cq *kueue.ClusterQueue)

func (*Cache) DeleteLocalQueue added in v0.2.0

func (c *Cache) DeleteLocalQueue(q *kueue.LocalQueue)

func (*Cache) DeleteResourceFlavor

func (c *Cache) DeleteResourceFlavor(rf *kueue.ResourceFlavor) sets.Set[string]

func (*Cache) DeleteWorkload

func (c *Cache) DeleteWorkload(w *kueue.Workload) error

func (*Cache) ForgetWorkload

func (c *Cache) ForgetWorkload(w *kueue.Workload) error

func (*Cache) IsAssumedOrAdmittedWorkload added in v0.3.0

func (c *Cache) IsAssumedOrAdmittedWorkload(w workload.Info) bool

func (*Cache) LocalQueueUsage added in v0.4.0

func (c *Cache) LocalQueueUsage(qObj *kueue.LocalQueue) (*LocalQueueUsageStats, error)

func (*Cache) MatchingClusterQueues added in v0.2.0

func (c *Cache) MatchingClusterQueues(nsLabels map[string]string) sets.Set[string]

func (*Cache) PodsReadyForAllAdmittedWorkloads added in v0.3.0

func (c *Cache) PodsReadyForAllAdmittedWorkloads(log logr.Logger) bool

func (*Cache) Snapshot

func (c *Cache) Snapshot() Snapshot

func (*Cache) TerminateClusterQueue added in v0.2.0

func (c *Cache) TerminateClusterQueue(name string)

func (*Cache) UpdateClusterQueue

func (c *Cache) UpdateClusterQueue(cq *kueue.ClusterQueue) error

func (*Cache) UpdateLocalQueue added in v0.2.0

func (c *Cache) UpdateLocalQueue(oldQ, newQ *kueue.LocalQueue) error

func (*Cache) UpdateWorkload

func (c *Cache) UpdateWorkload(oldWl, newWl *kueue.Workload) error

func (*Cache) Usage

func (c *Cache) Usage(cqObj *kueue.ClusterQueue) (*ClusterQueueUsageStats, error)

Usage reports the reserved and admitted resources and number of workloads holding them in the ClusterQueue.

func (*Cache) WaitForPodsReady added in v0.3.0

func (c *Cache) WaitForPodsReady(ctx context.Context)

WaitForPodsReady waits for all admitted workloads to be in the PodsReady condition if podsReadyTracking is enabled, otherwise returns immediately.

type ClusterQueue

type ClusterQueue struct {
	Name              string
	Cohort            *Cohort
	ResourceGroups    []ResourceGroup
	RGByResource      map[corev1.ResourceName]*ResourceGroup
	Usage             FlavorResourceQuantities
	AdmittedUsage     FlavorResourceQuantities
	Workloads         map[string]*workload.Info
	WorkloadsNotReady sets.Set[string]
	NamespaceSelector labels.Selector
	Preemption        kueue.ClusterQueuePreemption
	FlavorFungibility kueue.FlavorFungibility
	AdmissionChecks   sets.Set[string]
	Status            metrics.ClusterQueueStatus
	// GuaranteedQuota records how much resource quota the ClusterQueue reserved
	// when feature LendingLimit is enabled and flavor's lendingLimit is not nil.
	GuaranteedQuota FlavorResourceQuantities
	// AllocatableResourceGeneration will be increased when some admitted workloads are
	// deleted, or the resource groups are changed.
	AllocatableResourceGeneration int64
	// contains filtered or unexported fields
}

ClusterQueue is the internal implementation of kueue.ClusterQueue that holds admitted workloads.

func (*ClusterQueue) Active added in v0.2.0

func (c *ClusterQueue) Active() bool

func (*ClusterQueue) FitInCohort added in v0.6.0

func (c *ClusterQueue) FitInCohort(q FlavorResourceQuantities) bool

func (*ClusterQueue) IsBorrowing added in v0.3.2

func (c *ClusterQueue) IsBorrowing() bool

func (*ClusterQueue) RequestableCohortQuota added in v0.6.0

func (c *ClusterQueue) RequestableCohortQuota(fName kueue.ResourceFlavorReference, rName corev1.ResourceName) (val int64)

RequestableCohortQuota returns the total available quota by the flavor and resource name in the cohort. LendingLimit will also be counted here if feature LendingLimit enabled. Please note that for different clusterQueues, the requestable quota is different, they should be calculated dynamically.

func (*ClusterQueue) UpdateRGByResource added in v0.3.0

func (c *ClusterQueue) UpdateRGByResource()

func (*ClusterQueue) UpdateWithFlavors added in v0.2.0

func (c *ClusterQueue) UpdateWithFlavors(flavors map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor)

UpdateWithFlavors updates a ClusterQueue based on the passed ResourceFlavors set. Exported only for testing.

func (*ClusterQueue) UsedCohortQuota added in v0.6.0

func (c *ClusterQueue) UsedCohortQuota(fName kueue.ResourceFlavorReference, rName corev1.ResourceName) (val int64)

UsedCohortQuota returns the used quota by the flavor and resource name in the cohort. Note that when LendingLimit enabled, the usage is not equal to the total used quota but the one minus the guaranteed resources, this is only for judging whether workloads fit in the cohort.

type ClusterQueueUsageStats added in v0.5.0

type ClusterQueueUsageStats struct {
	ReservedResources  []kueue.FlavorUsage
	ReservingWorkloads int
	AdmittedResources  []kueue.FlavorUsage
	AdmittedWorkloads  int
}

type Cohort

type Cohort struct {
	Name    string
	Members sets.Set[*ClusterQueue]

	// These fields are only populated for a snapshot. This field equals to
	// the sum of LendingLimit when feature LendingLimit enabled.
	RequestableResources FlavorResourceQuantities
	Usage                FlavorResourceQuantities
	// This field will only be set in snapshot. This field equals to
	// the sum of allocatable generation among its members.
	AllocatableResourceGeneration int64
}

Cohort is a set of ClusterQueues that can borrow resources from each other.

type FlavorQuotas added in v0.3.0

type FlavorQuotas struct {
	Name      kueue.ResourceFlavorReference
	Resources map[corev1.ResourceName]*ResourceQuota
}

FlavorQuotas holds a processed ClusterQueue flavor quota.

type FlavorResourceQuantities added in v0.3.0

type FlavorResourceQuantities map[kueue.ResourceFlavorReference]map[corev1.ResourceName]int64

type LocalQueueUsageStats added in v0.5.0

type LocalQueueUsageStats struct {
	ReservedResources  []kueue.LocalQueueFlavorUsage
	ReservingWorkloads int
	AdmittedResources  []kueue.LocalQueueFlavorUsage
	AdmittedWorkloads  int
}

type Option added in v0.3.0

type Option func(*options)

Option configures the reconciler.

func WithPodsReadyTracking added in v0.3.0

func WithPodsReadyTracking(f bool) Option

WithPodsReadyTracking indicates the cache controller tracks the PodsReady condition for admitted workloads, and allows to block admission of new workloads until all admitted workloads are in the PodsReady condition.

type ResourceGroup added in v0.3.0

type ResourceGroup struct {
	CoveredResources sets.Set[corev1.ResourceName]
	Flavors          []FlavorQuotas
	// The set of key labels from all flavors.
	// Those keys define the affinity terms of a workload
	// that can be matched against the flavors.
	LabelKeys sets.Set[string]
}

type ResourceQuota added in v0.3.0

type ResourceQuota struct {
	Nominal        int64
	BorrowingLimit *int64
	LendingLimit   *int64
}

type Snapshot

type Snapshot struct {
	ClusterQueues            map[string]*ClusterQueue
	ResourceFlavors          map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor
	InactiveClusterQueueSets sets.Set[string]
}

func (*Snapshot) AddWorkload added in v0.3.0

func (s *Snapshot) AddWorkload(wl *workload.Info)

AddWorkload adds a workload from its corresponding ClusterQueue and updates resource usage.

func (*Snapshot) Log added in v0.6.0

func (s *Snapshot) Log(log logr.Logger)

func (*Snapshot) RemoveWorkload added in v0.3.0

func (s *Snapshot) RemoveWorkload(wl *workload.Info)

RemoveWorkload removes a workload from its corresponding ClusterQueue and updates resource usage.

Jump to

Keyboard shortcuts

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