-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Periodic Sync to periodically calculate and patch storagequota Reserv…
…ed values (#3075)
- Loading branch information
1 parent
4d85dd7
commit f98a445
Showing
9 changed files
with
688 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
pkg/apis/cnsoperator/storagequotaperiodicsync/v1alpha1/groupversion_info.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) 2024 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package v1alpha1 contains API Schema definitions for the cns v1alpha1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=cns.vmware.com | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "cns.vmware.com", Version: "v1alpha1"} | ||
|
||
// schemeBuilder is used to add go types to the GroupVersionKind scheme. | ||
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = schemeBuilder.AddToScheme | ||
|
||
objectTypes = []runtime.Object{} | ||
) | ||
|
||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(GroupVersion, objectTypes...) | ||
metav1.AddToGroupVersion(scheme, GroupVersion) | ||
return nil | ||
} |
62 changes: 62 additions & 0 deletions
62
pkg/apis/cnsoperator/storagequotaperiodicsync/v1alpha1/storagequotaperiodicsync_types.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) 2024 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/api/resource" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// StorageQuotaPeriodicSyncSpec defines the desired state of StorageQuotaPeriodicSync | ||
type StorageQuotaPeriodicSyncSpec struct { | ||
// SyncIntervalInMinutes is the time in minutes after which StorageQuota CR will be | ||
// synced periodically | ||
SyncIntervalInMinutes int `json:"syncIntervalInMinutes,omitempty"` | ||
} | ||
|
||
// StorageQuotaPeriodicSyncStatus defines the observed state of StorageQuotaPeriodicSync | ||
type StorageQuotaPeriodicSyncStatus struct { | ||
// LastSyncTimestamp defines the timestamp when last sync operation executed | ||
LastSyncTimestamp metav1.Time `json:"lastSyncTimestamp,omitempty"` | ||
|
||
// ExpectedReservedValues indicates the expected "reserved" value for each namespace | ||
// during each execution cycle | ||
ExpectedReservedValues []ExpectedReservedValues `json:"expectedReservedValues,omitempty"` | ||
} | ||
|
||
type ExpectedReservedValues struct { | ||
// Namespace is the namespace for which reserved values are calculated | ||
Namespace string `json:"namespace,omitempty"` | ||
|
||
// Reserved indicates the map of storagePolicyId to expected reserved value for that policy. | ||
// It is calculated by combining the sizes of pending PVC objects, pending PVC expands and not ready | ||
// VolumeSnapshots etc. for each storagePolicyId. | ||
Reserved map[string]*resource.Quantity `json:"reserved,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:storageversion | ||
|
||
// StorageQuotaPeriodicSync is the Schema for the storagequotaperiodicsync API | ||
type StorageQuotaPeriodicSync struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec StorageQuotaPeriodicSyncSpec `json:"spec,omitempty"` | ||
Status StorageQuotaPeriodicSyncStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// StorageQuotaPeriodicSyncList contains a list of StorageQuotaPeriodicSync | ||
type StorageQuotaPeriodicSyncList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []StorageQuotaPeriodicSync `json:"items"` | ||
} | ||
|
||
func init() { | ||
objectTypes = append(objectTypes, &StorageQuotaPeriodicSync{}, &StorageQuotaPeriodicSyncList{}) | ||
} |
Oops, something went wrong.