Skip to content

Commit a5b9f8e

Browse files
committed
apis: add protobuf for reservation
Signed-off-by: 佑祎 <zzw261520@alibaba-inc.com>
1 parent 18ba907 commit a5b9f8e

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

apis/scheduling/v1alpha1/reservation_types.go

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,44 @@ type ReservationSpec struct {
3535
// +kubebuilder:pruning:PreserveUnknownFields
3636
// +kubebuilder:validation:Schemaless
3737
// +kubebuilder:validation:Required
38-
Template *corev1.PodTemplateSpec `json:"template"`
38+
Template *corev1.PodTemplateSpec `json:"template" protobuf:"bytes,1,opt,name=template"`
3939
// Specify the owners who can allocate the reserved resources.
4040
// Multiple owner selectors and ORed.
4141
// +kubebuilder:validation:Required
4242
// +kubebuilder:validation:MinItems=1
43-
Owners []ReservationOwner `json:"owners"`
43+
Owners []ReservationOwner `json:"owners" protobuf:"bytes,2,rep,name=owners"`
4444
// Time-to-Live period for the reservation.
4545
// `expires` and `ttl` are mutually exclusive. Defaults to 24h. Set 0 to disable expiration.
4646
// +kubebuilder:default="24h"
4747
// +optional
48-
TTL *metav1.Duration `json:"ttl,omitempty"`
48+
TTL *metav1.Duration `json:"ttl,omitempty" protobuf:"bytes,3,opt,name=ttl"`
4949
// Expired timestamp when the reservation is expected to expire.
5050
// If both `expires` and `ttl` are set, `expires` is checked first.
5151
// `expires` and `ttl` are mutually exclusive. Defaults to being set dynamically at runtime based on the `ttl`.
5252
// +optional
53-
Expires *metav1.Time `json:"expires,omitempty"`
53+
Expires *metav1.Time `json:"expires,omitempty" protobuf:"bytes,4,opt,name=expires"`
5454
// By default, the resources requirements of reservation (specified in `template.spec`) is filtered by whether the
5555
// node has sufficient free resources (i.e. Reservation Request < Node Free).
5656
// When `preAllocation` is set, the scheduler will skip this validation and allow overcommitment. The scheduled
5757
// reservation would be waiting to be available until free resources are sufficient.
5858
// +optional
59-
PreAllocation bool `json:"preAllocation,omitempty"`
59+
PreAllocation bool `json:"preAllocation,omitempty" protobuf:"varint,5,opt,name=preAllocation"`
6060
// When `AllocateOnce` is set, the reserved resources are only available for the first owner who allocates successfully
6161
// and are not allocatable to other owners anymore. Defaults to true.
6262
// +kubebuilder:default=true
6363
// +optional
64-
AllocateOnce *bool `json:"allocateOnce,omitempty"`
64+
AllocateOnce *bool `json:"allocateOnce,omitempty" protobuf:"varint,6,opt,name=allocateOnce"`
6565
// AllocatePolicy represents the allocation policy of reserved resources that Reservation expects.
6666
// +kubebuilder:validation:Enum=Aligned;Restricted
6767
// +optional
68-
AllocatePolicy ReservationAllocatePolicy `json:"allocatePolicy,omitempty"`
68+
AllocatePolicy ReservationAllocatePolicy `json:"allocatePolicy,omitempty" protobuf:"bytes,7,opt,name=allocatePolicy,casttype=ReservationAllocatePolicy"`
6969
// Unschedulable controls reservation schedulability of new pods. By default, reservation is schedulable.
7070
// +optional
71-
Unschedulable bool `json:"unschedulable,omitempty"`
71+
Unschedulable bool `json:"unschedulable,omitempty" protobuf:"varint,8,opt,name=unschedulable"`
7272
// Specifies the reservation's taints. This can be toleranted by the reservation tolerance.
7373
// Eviction is not supported for NoExecute taints
7474
// +optional
75-
Taints []corev1.Taint `json:"taints,omitempty"`
75+
Taints []corev1.Taint `json:"taints,omitempty" protobuf:"bytes,9,rep,name=taints"`
7676
}
7777

7878
type ReservationAllocatePolicy string
@@ -101,11 +101,11 @@ type ReservationTemplateSpec struct {
101101
// Standard object's metadata.
102102
// +kubebuilder:pruning:PreserveUnknownFields
103103
// +optional
104-
metav1.ObjectMeta `json:"metadata,omitempty"`
104+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
105105

106106
// Specification of the desired behavior of the Reservation.
107107
// +optional
108-
Spec ReservationSpec `json:"spec,omitempty"`
108+
Spec ReservationSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
109109
}
110110

111111
type ReservationStatus struct {
@@ -115,40 +115,40 @@ type ReservationStatus struct {
115115
// The `phase` indicates whether is reservation is waiting for process, available to allocate or failed/expired to
116116
// get cleanup.
117117
// +optional
118-
Phase ReservationPhase `json:"phase,omitempty"`
118+
Phase ReservationPhase `json:"phase,omitempty" protobuf:"bytes,1,opt,name=phase,casttype=ReservationPhase"`
119119
// The `conditions` indicate the messages of reason why the reservation is still pending.
120120
// +optional
121-
Conditions []ReservationCondition `json:"conditions,omitempty"`
121+
Conditions []ReservationCondition `json:"conditions,omitempty" protobuf:"bytes,2,rep,name=conditions"`
122122
// Current resource owners which allocated the reservation resources.
123123
// +optional
124-
CurrentOwners []corev1.ObjectReference `json:"currentOwners,omitempty"`
124+
CurrentOwners []corev1.ObjectReference `json:"currentOwners,omitempty" protobuf:"bytes,3,rep,name=currentOwners"`
125125
// Name of node the reservation is scheduled on.
126126
// +optional
127-
NodeName string `json:"nodeName,omitempty"`
127+
NodeName string `json:"nodeName,omitempty" protobuf:"bytes,4,opt,name=nodeName"`
128128
// Resource reserved and allocatable for owners.
129129
// +optional
130-
Allocatable corev1.ResourceList `json:"allocatable,omitempty"`
130+
Allocatable corev1.ResourceList `json:"allocatable,omitempty" protobuf:"bytes,5,rep,name=allocatable,casttype=k8s.io/api/core/v1.ResourceList,castkey=k8s.io/api/core/v1.ResourceName"`
131131
// Resource allocated by current owners.
132132
// +optional
133-
Allocated corev1.ResourceList `json:"allocated,omitempty"`
133+
Allocated corev1.ResourceList `json:"allocated,omitempty" protobuf:"bytes,6,rep,name=allocated,casttype=k8s.io/api/core/v1.ResourceList,castkey=k8s.io/api/core/v1.ResourceName"`
134134
}
135135

136136
// ReservationOwner indicates the owner specification which can allocate reserved resources.
137137
// +kubebuilder:validation:MinProperties=1
138138
type ReservationOwner struct {
139139
// Multiple field selectors are ANDed.
140140
// +optional
141-
Object *corev1.ObjectReference `json:"object,omitempty"`
141+
Object *corev1.ObjectReference `json:"object,omitempty" protobuf:"bytes,1,opt,name=object"`
142142
// +optional
143-
Controller *ReservationControllerReference `json:"controller,omitempty"`
143+
Controller *ReservationControllerReference `json:"controller,omitempty" protobuf:"bytes,2,opt,name=controller"`
144144
// +optional
145-
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
145+
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty" protobuf:"bytes,3,opt,name=labelSelector"`
146146
}
147147

148148
type ReservationControllerReference struct {
149149
// Extend with a `namespace` field for reference different namespaces.
150-
metav1.OwnerReference `json:",inline"`
151-
Namespace string `json:"namespace,omitempty"`
150+
metav1.OwnerReference `json:",inline" protobuf:"bytes,1,opt,name=ownerReference"`
151+
Namespace string `json:"namespace,omitempty" protobuf:"bytes,2,opt,name=namespace"`
152152
}
153153

154154
type ReservationPhase string
@@ -194,12 +194,12 @@ const (
194194
)
195195

196196
type ReservationCondition struct {
197-
Type ReservationConditionType `json:"type,omitempty"`
198-
Status ConditionStatus `json:"status,omitempty"`
199-
Reason string `json:"reason,omitempty"`
200-
Message string `json:"message,omitempty"`
201-
LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"`
202-
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
197+
Type ReservationConditionType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=ReservationConditionType"`
198+
Status ConditionStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"`
199+
Reason string `json:"reason,omitempty" protobuf:"bytes,3,opt,name=reason"`
200+
Message string `json:"message,omitempty" protobuf:"bytes,4,opt,name=message"`
201+
LastProbeTime metav1.Time `json:"lastProbeTime,omitempty" protobuf:"bytes,5,opt,name=lastProbeTime"`
202+
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,6,opt,name=lastTransitionTime"`
203203
}
204204

205205
// +genclient
@@ -218,19 +218,19 @@ type ReservationCondition struct {
218218
// Any namespaced affinity/anti-affinity of reservation scheduling can be specified in the spec.template.
219219
type Reservation struct {
220220
metav1.TypeMeta `json:",inline"`
221-
metav1.ObjectMeta `json:"metadata,omitempty"`
221+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
222222

223-
Spec ReservationSpec `json:"spec,omitempty"`
224-
Status ReservationStatus `json:"status,omitempty"`
223+
Spec ReservationSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
224+
Status ReservationStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
225225
}
226226

227227
// +kubebuilder:object:root=true
228228

229229
// ReservationList contains a list of Reservation
230230
type ReservationList struct {
231231
metav1.TypeMeta `json:",inline"`
232-
metav1.ListMeta `json:"metadata,omitempty"`
233-
Items []Reservation `json:"items"`
232+
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
233+
Items []Reservation `json:"items" protobuf:"bytes,2,rep,name=items"`
234234
}
235235

236236
func init() {

0 commit comments

Comments
 (0)