mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-02-14 18:09:58 +00:00
feat: diverse performance improvements (#1861)
Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/projectcapsule/capsule/pkg/api"
|
||||
"github.com/projectcapsule/capsule/pkg/api/meta"
|
||||
)
|
||||
|
||||
// CapsuleConfigurationSpec defines the Capsule configuration.
|
||||
@@ -89,7 +90,7 @@ type DynamicAdmission struct {
|
||||
|
||||
type DynamicAdmissionConfig struct {
|
||||
// Name the Admission Webhook
|
||||
Name api.Name `json:"name,omitempty"`
|
||||
Name meta.RFC1123Name `json:"name,omitempty"`
|
||||
// Labels added to the Admission Webhook
|
||||
// +optional
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
|
||||
@@ -17,6 +17,9 @@ type NamespaceOptions struct {
|
||||
AdditionalMetadata *api.AdditionalMetadataSpec `json:"additionalMetadata,omitempty"`
|
||||
// Specifies additional labels and annotations the Capsule operator places on any Namespace resource in the Tenant via a list. Optional.
|
||||
AdditionalMetadataList []api.AdditionalMetadataSelectorSpec `json:"additionalMetadataList,omitempty"`
|
||||
// Required Metadata for namespace within this tenant
|
||||
// +optional
|
||||
RequiredMetadata *RequiredMetadata `json:"requiredMetadata,omitzero"`
|
||||
// Define the labels that a Tenant Owner cannot set for their Namespace resources.
|
||||
// +optional
|
||||
ForbiddenLabels api.ForbiddenListSpec `json:"forbiddenLabels,omitzero"`
|
||||
@@ -27,3 +30,13 @@ type NamespaceOptions struct {
|
||||
//+kubebuilder:default:=false
|
||||
ManagedMetadataOnly bool `json:"managedMetadataOnly,omitempty"`
|
||||
}
|
||||
|
||||
type RequiredMetadata struct {
|
||||
// Labels that must be defined for each namespace
|
||||
// +optional
|
||||
Labels map[string]string `json:"labels,omitzero"`
|
||||
|
||||
// Annotations that must be defined for each namespace
|
||||
// +optional
|
||||
Annotations map[string]string `json:"annotations,omitzero"`
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
|
||||
"github.com/projectcapsule/capsule/pkg/api"
|
||||
"github.com/projectcapsule/capsule/pkg/api/meta"
|
||||
)
|
||||
|
||||
func (r *ResourcePool) GetQuotaName() string {
|
||||
@@ -79,9 +79,10 @@ func (r *ResourcePool) AddClaimToStatus(claim *ResourcePoolClaim) {
|
||||
}
|
||||
|
||||
scl := &ResourcePoolClaimsItem{
|
||||
StatusNameUID: api.StatusNameUID{
|
||||
UID: claim.UID,
|
||||
Name: api.Name(claim.Name),
|
||||
NamespacedRFC1123ObjectReferenceWithNamespaceWithUID: meta.NamespacedRFC1123ObjectReferenceWithNamespaceWithUID{
|
||||
UID: claim.UID,
|
||||
Name: meta.RFC1123Name(claim.Name),
|
||||
Namespace: meta.RFC1123SubdomainName(claim.Namespace),
|
||||
},
|
||||
Claims: claim.Spec.ResourceClaims,
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/projectcapsule/capsule/pkg/api"
|
||||
"github.com/projectcapsule/capsule/pkg/api/meta"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -34,7 +33,7 @@ func TestGetClaimFromStatus(t *testing.T) {
|
||||
Claims: ResourcePoolNamespaceClaimsStatus{
|
||||
ns: {
|
||||
&ResourcePoolClaimsItem{
|
||||
StatusNameUID: api.StatusNameUID{
|
||||
NamespacedRFC1123ObjectReferenceWithNamespaceWithUID: meta.NamespacedRFC1123ObjectReferenceWithNamespaceWithUID{
|
||||
UID: testUID,
|
||||
},
|
||||
Claims: corev1.ResourceList{
|
||||
@@ -127,8 +126,9 @@ func TestAddRemoveClaimToStatus(t *testing.T) {
|
||||
pool.AddClaimToStatus(claim)
|
||||
|
||||
stored := pool.GetClaimFromStatus(claim)
|
||||
|
||||
assert.NotNil(t, stored)
|
||||
assert.Equal(t, api.Name("claim-1"), stored.Name)
|
||||
assert.Equal(t, meta.RFC1123Name("claim-1"), stored.Name)
|
||||
|
||||
pool.RemoveClaimFromStatus(claim)
|
||||
assert.Nil(t, pool.GetClaimFromStatus(claim))
|
||||
@@ -219,7 +219,7 @@ func TestGetNamespaceClaims(t *testing.T) {
|
||||
Claims: ResourcePoolNamespaceClaimsStatus{
|
||||
"ns": {
|
||||
&ResourcePoolClaimsItem{
|
||||
StatusNameUID: api.StatusNameUID{UID: "uid1"},
|
||||
NamespacedRFC1123ObjectReferenceWithNamespaceWithUID: meta.NamespacedRFC1123ObjectReferenceWithNamespaceWithUID{UID: "uid1"},
|
||||
Claims: corev1.ResourceList{
|
||||
corev1.ResourceLimitsCPU: resource.MustParse("1"),
|
||||
},
|
||||
@@ -260,36 +260,59 @@ func TestIsBoundToResourcePool_2(t *testing.T) {
|
||||
t.Run("bound to resource pool (Assigned=True)", func(t *testing.T) {
|
||||
claim := &ResourcePoolClaim{
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Condition: metav1.Condition{
|
||||
Type: meta.BoundCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
},
|
||||
Conditions: meta.ConditionList{},
|
||||
},
|
||||
}
|
||||
assert.Equal(t, true, claim.IsBoundToResourcePool())
|
||||
|
||||
assert.Equal(t, false, claim.IsBoundInResourcePool())
|
||||
})
|
||||
|
||||
t.Run("not bound - wrong condition type", func(t *testing.T) {
|
||||
claim := &ResourcePoolClaim{
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Condition: metav1.Condition{
|
||||
Type: "Other",
|
||||
Status: metav1.ConditionTrue,
|
||||
Conditions: meta.ConditionList{
|
||||
meta.Condition{},
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.Equal(t, false, claim.IsBoundToResourcePool())
|
||||
|
||||
cond := meta.NewAssignedCondition(claim)
|
||||
cond.Status = metav1.ConditionFalse
|
||||
claim.Status.Conditions.UpdateConditionByType(cond)
|
||||
|
||||
assert.Equal(t, false, claim.IsBoundInResourcePool())
|
||||
})
|
||||
|
||||
t.Run("not bound - condition not true", func(t *testing.T) {
|
||||
claim := &ResourcePoolClaim{
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Condition: metav1.Condition{
|
||||
Type: meta.BoundCondition,
|
||||
Status: metav1.ConditionFalse,
|
||||
Conditions: meta.ConditionList{
|
||||
meta.Condition{},
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.Equal(t, false, claim.IsBoundToResourcePool())
|
||||
|
||||
cond := meta.NewBoundCondition(claim)
|
||||
cond.Status = metav1.ConditionFalse
|
||||
claim.Status.Conditions.UpdateConditionByType(cond)
|
||||
|
||||
assert.Equal(t, false, claim.IsBoundInResourcePool())
|
||||
})
|
||||
|
||||
t.Run("not bound - condition not true", func(t *testing.T) {
|
||||
claim := &ResourcePoolClaim{
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Conditions: meta.ConditionList{
|
||||
meta.Condition{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cond := meta.NewBoundCondition(claim)
|
||||
cond.Status = metav1.ConditionTrue
|
||||
claim.Status.Conditions.UpdateConditionByType(cond)
|
||||
|
||||
assert.Equal(t, true, claim.IsBoundInResourcePool())
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/projectcapsule/capsule/pkg/api"
|
||||
"github.com/projectcapsule/capsule/pkg/api/meta"
|
||||
)
|
||||
|
||||
// GlobalResourceQuotaStatus defines the observed state of GlobalResourceQuota.
|
||||
@@ -28,6 +29,8 @@ type ResourcePoolStatus struct {
|
||||
Allocation ResourcePoolQuotaStatus `json:"allocation,omitzero"`
|
||||
// Exhaustions from claims associated with the pool
|
||||
Exhaustions map[string]api.PoolExhaustionResource `json:"exhaustions,omitempty"`
|
||||
// Conditions for the resource claim
|
||||
Conditions meta.ConditionList `json:"conditions,omitzero"`
|
||||
}
|
||||
|
||||
type ResourcePoolNamespaceClaimsStatus map[string]ResourcePoolClaimsList
|
||||
@@ -60,7 +63,7 @@ func (r *ResourcePoolClaimsList) GetClaimByUID(uid types.UID) *ResourcePoolClaim
|
||||
// ResourceQuotaClaimStatus defines the observed state of ResourceQuotaClaim.
|
||||
type ResourcePoolClaimsItem struct {
|
||||
// Reference to the GlobalQuota being claimed from
|
||||
api.StatusNameUID `json:",inline"`
|
||||
meta.NamespacedRFC1123ObjectReferenceWithNamespaceWithUID `json:",inline"`
|
||||
|
||||
// Claimed resources
|
||||
Claims corev1.ResourceList `json:"claims,omitempty"`
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/projectcapsule/capsule/pkg/api/misc"
|
||||
"github.com/projectcapsule/capsule/pkg/runtime/selectors"
|
||||
)
|
||||
|
||||
// ResourcePoolSpec.
|
||||
type ResourcePoolSpec struct {
|
||||
// Selector to match the namespaces that should be managed by the GlobalResourceQuota
|
||||
Selectors []misc.NamespaceSelector `json:"selectors,omitempty"`
|
||||
Selectors []selectors.NamespaceSelector `json:"selectors,omitempty"`
|
||||
// Define the resourcequota served by this resourcepool.
|
||||
Quota corev1.ResourceQuotaSpec `json:"quota"`
|
||||
// The Defaults given for each namespace, the default is not counted towards the total allocation
|
||||
@@ -27,7 +27,7 @@ type ResourcePoolSpec struct {
|
||||
}
|
||||
|
||||
type ResourcePoolSpecConfiguration struct {
|
||||
// With this option all resources which can be allocated are set to 0 for the resourcequota defaults.
|
||||
// With this option all resources which can be allocated are set to 0 for the resourcequota defaults. (Default false)
|
||||
// +kubebuilder:default=false
|
||||
DefaultsAssignZero *bool `json:"defaultsZero,omitempty"`
|
||||
// Claims are queued whenever they are allocated to a pool. A pool tries to allocate claims in order based on their
|
||||
@@ -35,11 +35,11 @@ type ResourcePoolSpecConfiguration struct {
|
||||
// but if a lower priority claim still has enough space in the available resources, it will be able to claim them. Eventough
|
||||
// it's priority was lower
|
||||
// Enabling this option respects to Order. Meaning the Creationtimestamp matters and if a resource is put into the queue, no
|
||||
// other claim can claim the same resources with lower priority.
|
||||
// other claim can claim the same resources with lower priority. (Default false)
|
||||
// +kubebuilder:default=false
|
||||
OrderedQueue *bool `json:"orderedQueue,omitempty"`
|
||||
// When a resourcepool is deleted, the resourceclaims bound to it are disassociated from the resourcepool but not deleted.
|
||||
// By Enabling this option, the resourceclaims will be deleted when the resourcepool is deleted, if they are in bound state.
|
||||
// By Enabling this option, the resourceclaims will be deleted when the resourcepool is deleted, if they are in bound state. (Default false)
|
||||
// +kubebuilder:default=false
|
||||
DeleteBoundResources *bool `json:"deleteBoundResources,omitempty"`
|
||||
}
|
||||
@@ -49,6 +49,8 @@ type ResourcePoolSpecConfiguration struct {
|
||||
// +kubebuilder:resource:scope=Cluster,shortName=quotapool
|
||||
// +kubebuilder:printcolumn:name="Claims",type="integer",JSONPath=".status.claimCount",description="The total amount of Claims bound"
|
||||
// +kubebuilder:printcolumn:name="Namespaces",type="integer",JSONPath=".status.namespaceCount",description="The total amount of Namespaces considered"
|
||||
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="Reconcile Status"
|
||||
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description="Reconcile Message"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age"
|
||||
|
||||
// Resourcepools allows you to define a set of resources as known from ResoureQuotas. The Resourcepools are defined at cluster-scope an should
|
||||
|
||||
@@ -10,11 +10,52 @@ import (
|
||||
)
|
||||
|
||||
// Indicate the claim is bound to a resource pool.
|
||||
func (r *ResourcePoolClaim) IsBoundToResourcePool() bool {
|
||||
if r.Status.Condition.Type == meta.BoundCondition &&
|
||||
r.Status.Condition.Status == metav1.ConditionTrue {
|
||||
func (r *ResourcePoolClaim) IsExhaustedInResourcePool() bool {
|
||||
condition := r.Status.Conditions.GetConditionByType(meta.ExhaustedCondition)
|
||||
|
||||
if condition == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if condition.Status == metav1.ConditionTrue {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *ResourcePoolClaim) IsAssignedInResourcePool() bool {
|
||||
condition := r.Status.Conditions.GetConditionByType(meta.AssignedCondition)
|
||||
|
||||
if condition == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if condition.Status == metav1.ConditionTrue {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *ResourcePoolClaim) IsBoundInResourcePool() bool {
|
||||
condition := r.Status.Conditions.GetConditionByType(meta.BoundCondition)
|
||||
|
||||
if condition == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if condition.Status == metav1.ConditionTrue {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *ResourcePoolClaim) GetPool() string {
|
||||
if name := string(r.Status.Pool.Name); name != "" {
|
||||
return name
|
||||
}
|
||||
|
||||
return r.Spec.Pool
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@ package v1beta2
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/projectcapsule/capsule/pkg/api/meta"
|
||||
"github.com/stretchr/testify/assert"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/projectcapsule/capsule/pkg/api/meta"
|
||||
)
|
||||
|
||||
func TestIsBoundToResourcePool(t *testing.T) {
|
||||
@@ -21,9 +22,14 @@ func TestIsBoundToResourcePool(t *testing.T) {
|
||||
name: "bound to resource pool (Assigned=True)",
|
||||
claim: ResourcePoolClaim{
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Condition: metav1.Condition{
|
||||
Type: meta.BoundCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Conditions: meta.ConditionList{
|
||||
meta.Condition{
|
||||
Type: meta.BoundCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: meta.SucceededReason,
|
||||
Message: "reconciled",
|
||||
LastTransitionTime: metav1.Now(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -33,9 +39,14 @@ func TestIsBoundToResourcePool(t *testing.T) {
|
||||
name: "not bound - wrong condition type",
|
||||
claim: ResourcePoolClaim{
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Condition: metav1.Condition{
|
||||
Type: "SomethingElse",
|
||||
Status: metav1.ConditionTrue,
|
||||
Conditions: meta.ConditionList{
|
||||
meta.Condition{
|
||||
Type: meta.AssignedCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: meta.SucceededReason,
|
||||
Message: "reconciled",
|
||||
LastTransitionTime: metav1.Now(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -45,9 +56,14 @@ func TestIsBoundToResourcePool(t *testing.T) {
|
||||
name: "not bound - status not true",
|
||||
claim: ResourcePoolClaim{
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Condition: metav1.Condition{
|
||||
Type: meta.BoundCondition,
|
||||
Status: metav1.ConditionFalse,
|
||||
Conditions: meta.ConditionList{
|
||||
meta.Condition{
|
||||
Type: meta.AssignedCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: meta.SucceededReason,
|
||||
Message: "reconciled",
|
||||
LastTransitionTime: metav1.Now(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -64,7 +80,91 @@ func TestIsBoundToResourcePool(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
actual := tt.claim.IsBoundToResourcePool()
|
||||
actual := tt.claim.IsBoundInResourcePool()
|
||||
assert.Equal(t, tt.expected, actual)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPool(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
claim ResourcePoolClaim
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "returns status pool name when set",
|
||||
claim: ResourcePoolClaim{
|
||||
Spec: ResourcePoolClaimSpec{
|
||||
Pool: "spec-pool",
|
||||
},
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Pool: meta.LocalRFC1123ObjectReferenceWithUID{
|
||||
Name: meta.RFC1123Name("status-pool"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: "status-pool",
|
||||
},
|
||||
{
|
||||
name: "falls back to spec pool when status pool name is empty",
|
||||
claim: ResourcePoolClaim{
|
||||
Spec: ResourcePoolClaimSpec{
|
||||
Pool: "spec-pool",
|
||||
},
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Pool: meta.LocalRFC1123ObjectReferenceWithUID{
|
||||
Name: meta.RFC1123Name(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: "spec-pool",
|
||||
},
|
||||
{
|
||||
name: "falls back to spec pool when status pool struct is zero-value",
|
||||
claim: ResourcePoolClaim{
|
||||
Spec: ResourcePoolClaimSpec{
|
||||
Pool: "spec-pool",
|
||||
},
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Pool: meta.LocalRFC1123ObjectReferenceWithUID{},
|
||||
},
|
||||
},
|
||||
expected: "spec-pool",
|
||||
},
|
||||
{
|
||||
name: "returns empty when both status and spec are empty",
|
||||
claim: ResourcePoolClaim{
|
||||
Spec: ResourcePoolClaimSpec{
|
||||
Pool: "",
|
||||
},
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Pool: meta.LocalRFC1123ObjectReferenceWithUID{
|
||||
Name: meta.RFC1123Name(""),
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
name: "status wins even if spec differs",
|
||||
claim: ResourcePoolClaim{
|
||||
Spec: ResourcePoolClaimSpec{
|
||||
Pool: "spec-pool",
|
||||
},
|
||||
Status: ResourcePoolClaimStatus{
|
||||
Pool: meta.LocalRFC1123ObjectReferenceWithUID{
|
||||
Name: meta.RFC1123Name("status-pool"),
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: "status-pool",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
actual := tt.claim.GetPool()
|
||||
assert.Equal(t, tt.expected, actual)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/projectcapsule/capsule/pkg/api"
|
||||
"github.com/projectcapsule/capsule/pkg/api/meta"
|
||||
)
|
||||
|
||||
type ResourcePoolClaimSpec struct {
|
||||
@@ -23,20 +23,26 @@ type ResourcePoolClaimSpec struct {
|
||||
type ResourcePoolClaimStatus struct {
|
||||
// Reference to the GlobalQuota being claimed from
|
||||
// +optional
|
||||
Pool api.StatusNameUID `json:"pool,omitzero"`
|
||||
// Condtion for this resource claim
|
||||
Pool meta.LocalRFC1123ObjectReferenceWithUID `json:"pool,omitzero"`
|
||||
// Deprecated: Use Conditions
|
||||
//
|
||||
// +optional
|
||||
Condition metav1.Condition `json:"condition,omitzero"`
|
||||
// Conditions for the resource claim
|
||||
Conditions meta.ConditionList `json:"conditions,omitzero"`
|
||||
// Tracks the Usage from Claimed from this claim and available resources
|
||||
// +optional
|
||||
Allocation ResourcePoolQuotaStatus `json:"allocation,omitzero"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="Pool",type="string",JSONPath=".status.pool.name",description="The ResourcePool being claimed from"
|
||||
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.condition.type",description="Status for claim"
|
||||
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.condition.reason",description="Reason for status"
|
||||
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.condition.message",description="Condition Message"
|
||||
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="Ready Status"
|
||||
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description="Ready Message"
|
||||
// +kubebuilder:printcolumn:name="Bound",type="string",JSONPath=".status.conditions[?(@.type==\"Bound\")].status",description="Bound Status"
|
||||
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type==\"Bound\")].message",description="Bound Message"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
|
||||
|
||||
// ResourcePoolClaim is the Schema for the resourcepoolclaims API.
|
||||
type ResourcePoolClaim struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
@@ -51,7 +57,6 @@ type ResourcePoolClaim struct {
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ResourceQuotaClaimList contains a list of ResourceQuotaClaim.
|
||||
type ResourcePoolClaimList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/projectcapsule/capsule/pkg/api"
|
||||
"github.com/projectcapsule/capsule/pkg/api/meta"
|
||||
"github.com/projectcapsule/capsule/pkg/api/misc"
|
||||
"github.com/projectcapsule/capsule/pkg/runtime/selectors"
|
||||
)
|
||||
|
||||
// TenantSpec defines the desired state of Tenant.
|
||||
@@ -122,7 +122,7 @@ func (p *Permissions) ListMatchingOwners(
|
||||
},
|
||||
}
|
||||
|
||||
return misc.ListBySelectors[*TenantOwner](ctx, c, &TenantOwnerList{}, append(p.MatchOwners, defaultSelector))
|
||||
return selectors.ListBySelectors[*TenantOwner](ctx, c, &TenantOwnerList{}, append(p.MatchOwners, defaultSelector))
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
@@ -151,11 +151,7 @@ type Tenant struct {
|
||||
}
|
||||
|
||||
func (in *Tenant) GetNamespaces() (res []string) {
|
||||
res = make([]string, 0, len(in.Status.Namespaces))
|
||||
|
||||
res = append(res, in.Status.Namespaces...)
|
||||
|
||||
return res
|
||||
return in.Status.Namespaces
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
@@ -10,7 +10,7 @@ package v1beta2
|
||||
import (
|
||||
"github.com/projectcapsule/capsule/pkg/api"
|
||||
"github.com/projectcapsule/capsule/pkg/api/meta"
|
||||
"github.com/projectcapsule/capsule/pkg/api/misc"
|
||||
"github.com/projectcapsule/capsule/pkg/runtime/selectors"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/rbac/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -398,6 +398,11 @@ func (in *NamespaceOptions) DeepCopyInto(out *NamespaceOptions) {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.RequiredMetadata != nil {
|
||||
in, out := &in.RequiredMetadata, &out.RequiredMetadata
|
||||
*out = new(RequiredMetadata)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
in.ForbiddenLabels.DeepCopyInto(&out.ForbiddenLabels)
|
||||
in.ForbiddenAnnotations.DeepCopyInto(&out.ForbiddenAnnotations)
|
||||
}
|
||||
@@ -637,6 +642,35 @@ func (in *RawExtension) DeepCopy() *RawExtension {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RequiredMetadata) DeepCopyInto(out *RequiredMetadata) {
|
||||
*out = *in
|
||||
if in.Labels != nil {
|
||||
in, out := &in.Labels, &out.Labels
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.Annotations != nil {
|
||||
in, out := &in.Annotations, &out.Annotations
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RequiredMetadata.
|
||||
func (in *RequiredMetadata) DeepCopy() *RequiredMetadata {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(RequiredMetadata)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ResourcePool) DeepCopyInto(out *ResourcePool) {
|
||||
*out = *in
|
||||
@@ -750,6 +784,14 @@ func (in *ResourcePoolClaimStatus) DeepCopyInto(out *ResourcePoolClaimStatus) {
|
||||
*out = *in
|
||||
out.Pool = in.Pool
|
||||
in.Condition.DeepCopyInto(&out.Condition)
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make(meta.ConditionList, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
in.Allocation.DeepCopyInto(&out.Allocation)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourcePoolClaimStatus.
|
||||
@@ -765,7 +807,7 @@ func (in *ResourcePoolClaimStatus) DeepCopy() *ResourcePoolClaimStatus {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ResourcePoolClaimsItem) DeepCopyInto(out *ResourcePoolClaimsItem) {
|
||||
*out = *in
|
||||
out.StatusNameUID = in.StatusNameUID
|
||||
out.NamespacedRFC1123ObjectReferenceWithNamespaceWithUID = in.NamespacedRFC1123ObjectReferenceWithNamespaceWithUID
|
||||
if in.Claims != nil {
|
||||
in, out := &in.Claims, &out.Claims
|
||||
*out = make(corev1.ResourceList, len(*in))
|
||||
@@ -919,7 +961,7 @@ func (in *ResourcePoolSpec) DeepCopyInto(out *ResourcePoolSpec) {
|
||||
*out = *in
|
||||
if in.Selectors != nil {
|
||||
in, out := &in.Selectors, &out.Selectors
|
||||
*out = make([]misc.NamespaceSelector, len(*in))
|
||||
*out = make([]selectors.NamespaceSelector, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
@@ -1013,6 +1055,13 @@ func (in *ResourcePoolStatus) DeepCopyInto(out *ResourcePoolStatus) {
|
||||
(*out)[key] = *val.DeepCopy()
|
||||
}
|
||||
}
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make(meta.ConditionList, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourcePoolStatus.
|
||||
|
||||
Reference in New Issue
Block a user