Files
capsule/api/v1beta2/quantityledgers_status.go
T
cc4fb45d70 feat: upstream enterprise preview (#1841)
feat: upstream enterprise preview

---------

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>
Co-authored-by: CorentinPtrl <pitrel.corentin@gmail.com>
2026-05-28 00:58:58 +02:00

69 lines
2.4 KiB
Go

// Copyright 2020-2026 Project Capsule Authors
// SPDX-License-Identifier: Apache-2.0
package v1beta2
import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/projectcapsule/capsule/pkg/api/meta"
)
// QuantityLedgerReservation represents one active inflight reservation.
// ID should be stable for retries of the same admission request.
// In practice, admission.Request.UID is a good default.
type QuantityLedgerReservation struct {
// Unique reservation identifier.
// +kubebuilder:validation:MinLength=1
ID string `json:"id"`
// Amount reserved for this request.
Usage resource.Quantity `json:"usage"`
// Object that this reservation is intended to create/update.
ObjectRef QuantityLedgerObjectRef `json:"objectRef"`
// Time the reservation was first created.
CreatedAt metav1.Time `json:"createdAt"`
// Time the reservation was last refreshed or updated.
UpdatedAt metav1.Time `json:"updatedAt"`
// Time after which the reservation may be considered stale.
// +optional
ExpiresAt *metav1.Time `json:"expiresAt,omitempty"`
}
// QuantityLedgerPendingDelete tracks objects that are expected to disappear from claims
// soon, but may still temporarily appear during rebuild due to propagation delay.
type QuantityLedgerPendingDelete struct {
ObjectRef QuantityLedgerObjectRef `json:"objectRef"`
CreatedAt metav1.Time `json:"createdAt"`
}
// QuantityLedgerStatus contains the mutable coordination state used by admission
// and quota controllers.
type QuantityLedgerStatus struct {
// Reserved is the aggregate sum of all active reservations.
// Controllers/webhooks should treat this as derived data from Reservations.
// +optional
Reserved resource.Quantity `json:"reserved,omitempty"`
// Active inflight reservations for this quota.
// +optional
Reservations []QuantityLedgerReservation `json:"reservations,omitempty"`
// Pending delete hints carried over from admission delete handling.
// +optional
PendingDeletes []QuantityLedgerPendingDelete `json:"pendingDeletes,omitempty"`
// Conditions for the resource claim
// +optional
Conditions meta.ConditionList `json:"conditions,omitzero"`
// Allocated is the admission-owned total that has been accepted by the webhook.
// It must be updated only through optimistic concurrency on QuantityLedger.
Allocated resource.Quantity `json:"allocated,omitempty"`
}