Skip to content

Commit 727c83d

Browse files
committed
autoscaling: add new crd for automatic storagescaling
added a new crd for automatic storage scaling Signed-off-by: parth-gr <[email protected]>
1 parent b0b6811 commit 727c83d

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed

PROJECT

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ resources:
2525
kind: OCSInitialization
2626
path: github.com/red-hat-storage/ocs-operator/api/v4/v1
2727
version: v1
28+
- api:
29+
crdVersion: v1
30+
namespaced: true
31+
controller: true
32+
domain: openshift.io
33+
group: ocs
34+
kind: StorageAutoScaler
35+
path: github.com/red-hat-storage/ocs-operator/api/v4/v1
36+
version: v1
2837
- api:
2938
crdVersion: v1
3039
namespaced: true

api/v1/groupversion_info.go

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
4444
&OCSInitialization{}, &OCSInitializationList{},
4545
&StorageCluster{}, &StorageClusterList{},
4646
&StorageClusterPeer{}, &StorageClusterPeerList{},
47+
&StorageAutoScaler{}, &StorageAutoScalerList{},
4748
)
4849
metav1.AddToGroupVersion(scheme, GroupVersion)
4950
return nil

api/v1/storageautoscaler_types.go

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
Copyright 2025 Red Hat OpenShift Container Storage.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
"k8s.io/apimachinery/pkg/api/resource"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
)
24+
25+
// StorageAutoScalerSpec defines the desired state of StorageAutoScaler
26+
type StorageAutoScalerSpec struct {
27+
// StorageCluster is the name of the storage cluster for which the storage scaling is to be done.
28+
// +kubebuilder:validation:Required
29+
StorageCluster corev1.LocalObjectReference `json:"storageCluster,omitempty"`
30+
// DeviceClass is the name of the device class for which the storage scaling is to be done.
31+
// +kubebuilder:validation:Optional
32+
// +kubebuilder:default="ssd"
33+
DeviceClass string `json:"deviceClass,omitempty"`
34+
// StorageCapacityLimit is the total aggregate capacity limit for the storage scaling for the specific deviceClass and storagecluster.
35+
// +kubebuilder:validation:Required
36+
StorageCapacityLimit resource.Quantity `json:"storageCapacityLimit,omitempty"`
37+
// MaxOsdSize is the maximum size that Osd disk can be expanded to.
38+
// +kubebuilder:validation:Optional
39+
// +kubebuilder:default="8Ti"
40+
MaxOsdSize resource.Quantity `json:"maxOsdSize,omitempty"`
41+
// StorageScalingThresholdPercent is the threshold percentage of the storage capacity that triggers the auto-scaling of the OSDs.
42+
// Should be less than the OsdNearFullThresholdPercentage.
43+
// +kubebuilder:validation:Optional
44+
// +kubebuilder:default=70
45+
StorageScalingThresholdPercent int `json:"storageScalingThresholdPercent,omitempty"`
46+
// TimeoutSeconds is the time in seconds after which the storage auto-scaler will alert the user that the scaling operation has been failed.
47+
// +kubebuilder:validation:Optional
48+
// +kubebuilder:default=1800
49+
TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
50+
}
51+
52+
type StorageAutoScalerPhase string
53+
54+
const (
55+
StorageAutoScalerPhaseNotStarted StorageAutoScalerPhase = "NotStarted"
56+
StorageAutoScalerPhaseInProgress StorageAutoScalerPhase = "InProgress"
57+
StorageAutoScalerPhaseSucceeded StorageAutoScalerPhase = "Succeeded"
58+
StorageAutoScalerPhaseFailed StorageAutoScalerPhase = "Failed"
59+
)
60+
61+
// TimestampedError is the error message with the time stamp.
62+
type TimestampedError struct {
63+
// Message is the error message in case the storage scaling operation has failed.
64+
Message string `json:"message,omitempty"`
65+
// Timestamp is the time stamp when the error occurred.
66+
Timestamp metav1.Time `json:"timestamp,omitempty"`
67+
}
68+
69+
type LastExpansionStatus struct {
70+
// StartTime is the time stamp of the last run start of the storage scaling
71+
// +optional
72+
StartTime metav1.Time `json:"startTime,omitempty"`
73+
// CompletionTime is the time stamp of the last run completion of the storage scaling
74+
// +optional
75+
CompletionTime metav1.Time `json:"completionTime,omitempty"`
76+
// The start OSD size is the original size of the OSDs before the expansion in progress is completed.
77+
// After the expansion is completed, this would be updated to the expected OSD size.
78+
// Used for vertical scaling of OSDs.
79+
// +optional
80+
StartOsdSize resource.Quantity `json:"startOsdSize,omitempty"`
81+
// The ExpectedOsdSize is the size that the auto-expansion has decided to set.
82+
// This will be set on the storageCLuster CR as the desired size of the OSDs.
83+
// Used for vertical scaling of OSDs.
84+
// +optional
85+
ExpectedOsdSize resource.Quantity `json:"expectedOsdSize,omitempty"`
86+
// The start OSD count is the original count of the OSDs before the expansion in progress is completed.
87+
// After the expansion is completed, this would be updated to the expected OSD count.
88+
// Used for horizontal scaling of OSDs.
89+
// +optional
90+
StartOsdCount uint16 `json:"startOsdCount,omitempty"`
91+
// The Expected OSD count is the count that the auto-expansion has decided to set.
92+
// This will be set on the storageCluster CR as the desired count of the OSDs.
93+
// Used for horizontal scaling of OSDs.
94+
// +optional
95+
ExpectedOsdCount uint16 `json:"expectedOsdCount,omitempty"`
96+
// StartStorageCapacity is the original storage capacity of the storage cluster before the expansion in progress is completed.
97+
StartStorageCapacity resource.Quantity `json:"startStorageCapacity,omitempty"`
98+
// ExpectedStorageCapacity is the expected storage capacity of the storage cluster after the expansion in progress is completed.
99+
ExpectedStorageCapacity resource.Quantity `json:"expectedStorageCapacity,omitempty"`
100+
}
101+
102+
// StorageAutoScalerStatus defines the observed state of StorageAutoScaler
103+
type StorageAutoScalerStatus struct {
104+
// Phase describes the Phase of StorageAutoScaler
105+
// +optional
106+
Phase StorageAutoScalerPhase `json:"phase,omitempty"`
107+
// Error is the error message in case the storage scaling operation has failed.
108+
// +optional
109+
// +nullable
110+
Error *TimestampedError `json:"error,omitempty"`
111+
// +optional
112+
// +nullable
113+
LastExpansion *LastExpansionStatus `json:"lastExpansion,omitempty"`
114+
// StorageCapacityLimitReached is the flag that indicates if the storage capacity limit has been reached.
115+
// +optional
116+
// +nullable
117+
StorageCapacityLimitReached *bool `json:"storageCapacityLimitReached,omitempty"`
118+
}
119+
120+
// +kubebuilder:object:root=true
121+
// +kubebuilder:subresource:status
122+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=.metadata.creationTimestamp, description="Age"
123+
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=.status.phase,description="Current Phase"
124+
// +kubebuilder:printcolumn:name="DeviceClass",type=string,JSONPath=.spec.deviceClass,description="Device Class"
125+
// +kubebuilder:printcolumn:name="LastRunTimeStamp",type=date,JSONPath=.status.lastRunTimeStamp,description="Last Run Time Stamp"
126+
// +operator-sdk:csv:customresourcedefinitions:displayName="Storage Auto Scaling"
127+
128+
// StorageAutoScaler represents the automatic storage scaling for storage cluster.
129+
type StorageAutoScaler struct {
130+
metav1.TypeMeta `json:",inline"`
131+
metav1.ObjectMeta `json:"metadata,omitempty"`
132+
133+
Spec StorageAutoScalerSpec `json:"spec,omitempty"`
134+
Status StorageAutoScalerStatus `json:"status,omitempty"`
135+
}
136+
137+
//+kubebuilder:object:root=true
138+
139+
// StorageAutoScalerList contains a list of StorageAutoScaler
140+
type StorageAutoScalerList struct {
141+
metav1.TypeMeta `json:",inline"`
142+
metav1.ListMeta `json:"metadata,omitempty"`
143+
Items []StorageAutoScaler `json:"items"`
144+
}

0 commit comments

Comments
 (0)