Documentation
¶
Index ¶
- Constants
- type Calculator
- func (c *Calculator) ApplyUsageOperation(currentUsage *tfv1.GPUResourceUsage, allocation *tfv1.AllocRequest, ...)
- func (c *Calculator) CalculateAvailablePercent(quota *tfv1.GPUResourceQuota, usage *tfv1.GPUResourceUsage) *tfv1.GPUResourceAvailablePercent
- func (c *Calculator) CalculateConditions(availablePercent *tfv1.GPUResourceAvailablePercent, alertThreshold int32, ...) []metav1.Condition
- func (c *Calculator) CreateZeroUsage() *tfv1.GPUResourceUsage
- func (c *Calculator) DecreaseUsage(usage *tfv1.GPUResourceUsage, allocation *tfv1.AllocRequest)
- func (c *Calculator) IncreaseUsage(usage *tfv1.GPUResourceUsage, allocation *tfv1.AllocRequest)
- func (c *Calculator) IsAlertThresholdReached(availablePercent string, threshold int32) bool
- func (c *Calculator) SafeAdd(a *resource.Quantity, b resource.Quantity, count int64)
- func (c *Calculator) SafeSub(a *resource.Quantity, b resource.Quantity, count int64)
- type QuotaExceededError
- type QuotaStore
- func (qs *QuotaStore) AdjustQuota(namespace string, reqDelta tfv1.Resource, limitDelta tfv1.Resource)
- func (qs *QuotaStore) AllocateQuota(namespace string, req *tfv1.AllocRequest)
- func (qs *QuotaStore) CheckQuotaAvailable(namespace string, req *tfv1.AllocRequest) error
- func (qs *QuotaStore) CheckTotalQuotaRelaxed(req *tfv1.AllocRequest, toReleaseResource *tfv1.GPUResourceUsage) error
- func (qs *QuotaStore) DeallocateQuota(namespace string, allocation *tfv1.AllocRequest)
- func (qs *QuotaStore) GetQuotaStatus(namespace string) (*tfv1.GPUResourceUsage, bool)
- func (qs *QuotaStore) InitQuotaStore() error
- func (qs *QuotaStore) ReconcileQuotaStore(ctx context.Context, namespacedAllocations map[string]*tfv1.AllocRequest)
- func (qs *QuotaStore) StartInformerForGPUQuota(ctx context.Context, mgr manager.Manager) error
- func (qs *QuotaStore) SyncQuotasToK8s(ctx context.Context)
- type QuotaStoreEntry
Constants ¶
const ( MaxTFlopsLimitResource = "single.max.tflops.limit" MaxVRAMLimitResource = "single.max.vram.limit" MaxTFlopsRequestResource = "single.max.tflops.request" MaxVRAMRequestResource = "single.max.vram.request" MaxGPULimitResource = "single.max.gpuCount.limit" TotalMaxTFlopsLimitResource = "total.max.tflops.limit" TotalMaxVRAMLimitResource = "total.max.vram.limit" TotalMaxTFlopsRequestResource = "total.max.tflops.request" TotalMaxVRAMRequestResource = "total.max.vram.request" TotalMaxWorkersLimitResource = "total.max.workers.limit" DefaultAlertThresholdPercent = int32(95) )
const QuotaReadyAndCapacitySufficient = "GPUResourceQuota is ready and capacity is sufficient"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Calculator ¶
type Calculator struct{}
Calculator provides shared quota calculation logic
func (*Calculator) ApplyUsageOperation ¶
func (c *Calculator) ApplyUsageOperation(currentUsage *tfv1.GPUResourceUsage, allocation *tfv1.AllocRequest, isIncrease bool)
ApplyUsageOperation atomically applies a usage operation (increase or decrease)
func (*Calculator) CalculateAvailablePercent ¶
func (c *Calculator) CalculateAvailablePercent(quota *tfv1.GPUResourceQuota, usage *tfv1.GPUResourceUsage) *tfv1.GPUResourceAvailablePercent
CalculateAvailablePercent calculates available percentage for each resource
func (*Calculator) CalculateConditions ¶ added in v1.35.0
func (c *Calculator) CalculateConditions(availablePercent *tfv1.GPUResourceAvailablePercent, alertThreshold int32, previousMsg string) []metav1.Condition
CreateStandardConditions creates standard quota conditions
func (*Calculator) CreateZeroUsage ¶
func (c *Calculator) CreateZeroUsage() *tfv1.GPUResourceUsage
CreateZeroUsage creates a zero-initialized usage object
func (*Calculator) DecreaseUsage ¶
func (c *Calculator) DecreaseUsage(usage *tfv1.GPUResourceUsage, allocation *tfv1.AllocRequest)
DecreaseUsage safely decreases resource usage with bounds checking
func (*Calculator) IncreaseUsage ¶
func (c *Calculator) IncreaseUsage(usage *tfv1.GPUResourceUsage, allocation *tfv1.AllocRequest)
IncreaseUsage safely increases resource usage
func (*Calculator) IsAlertThresholdReached ¶
func (c *Calculator) IsAlertThresholdReached(availablePercent string, threshold int32) bool
IsAlertThresholdReached checks if alert threshold is reached for any resource
type QuotaExceededError ¶ added in v1.35.0
type QuotaExceededError struct { Namespace string Resource string Requested resource.Quantity Limit resource.Quantity Unresolvable bool }
QuotaExceededError represents a quota exceeded error with detailed information
func (*QuotaExceededError) Error ¶ added in v1.35.0
func (e *QuotaExceededError) Error() string
type QuotaStore ¶ added in v1.35.0
type QuotaStore struct { client.Client // In-memory quota store: namespace -> quota info QuotaStore map[string]*QuotaStoreEntry StoreMutex sync.RWMutex // Calculator for shared quota computation logic Calculator *Calculator // contains filtered or unexported fields }
QuotaStore manages GPU resource quotas in memory for atomic operations
func NewQuotaStore ¶ added in v1.35.0
func NewQuotaStore(client client.Client, ctx context.Context) *QuotaStore
NewQuotaStore creates a new quota store
func (*QuotaStore) AdjustQuota ¶ added in v1.35.0
func (*QuotaStore) AllocateQuota ¶ added in v1.35.0
func (qs *QuotaStore) AllocateQuota(namespace string, req *tfv1.AllocRequest)
AllocateQuota atomically allocates quota resources This function is called under GPU allocator's storeMutex
func (*QuotaStore) CheckQuotaAvailable ¶ added in v1.35.0
func (qs *QuotaStore) CheckQuotaAvailable(namespace string, req *tfv1.AllocRequest) error
CheckQuotaAvailable is the quota checking logic Note: This method assumes proper locking is handled by the caller
func (*QuotaStore) CheckTotalQuotaRelaxed ¶ added in v1.44.0
func (qs *QuotaStore) CheckTotalQuotaRelaxed(req *tfv1.AllocRequest, toReleaseResource *tfv1.GPUResourceUsage) error
func (*QuotaStore) DeallocateQuota ¶ added in v1.35.0
func (qs *QuotaStore) DeallocateQuota(namespace string, allocation *tfv1.AllocRequest)
DeallocateQuota atomically deallocate quota resources This function is called under GPU allocator's storeMutex
func (*QuotaStore) GetQuotaStatus ¶ added in v1.35.0
func (qs *QuotaStore) GetQuotaStatus(namespace string) (*tfv1.GPUResourceUsage, bool)
GetQuotaStatus returns current quota status for a namespace
func (*QuotaStore) InitQuotaStore ¶ added in v1.35.0
func (qs *QuotaStore) InitQuotaStore() error
initQuotaStore initializes the quota store from Kubernetes
func (*QuotaStore) ReconcileQuotaStore ¶ added in v1.35.0
func (qs *QuotaStore) ReconcileQuotaStore(ctx context.Context, namespacedAllocations map[string]*tfv1.AllocRequest)
ReconcileQuotaStore rebuilds quota usage from actual worker pods
func (*QuotaStore) StartInformerForGPUQuota ¶ added in v1.35.0
func (*QuotaStore) SyncQuotasToK8s ¶ added in v1.35.0
func (qs *QuotaStore) SyncQuotasToK8s(ctx context.Context)
syncQuotasToK8s syncs dirty quotas to Kubernetes
type QuotaStoreEntry ¶ added in v1.35.0
type QuotaStoreEntry struct { // Original Quota definition from K8s Quota *tfv1.GPUResourceQuota // Current usage calculated in memory (authoritative) CurrentUsage *tfv1.GPUResourceUsage }
QuotaStoreEntry represents quota information in memory