Skip to content

Commit fbe25e1

Browse files
authored
Merge pull request #6121 from kisieland/prov-req-address-comments
Address comments from #6104
2 parents d447a6f + 5155725 commit fbe25e1

File tree

35 files changed

+151
-97
lines changed

35 files changed

+151
-97
lines changed

cluster-autoscaler/config/crd/autoscaling.x-k8s.io_provisioningrequests.yaml

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,20 @@ spec:
4343
type: object
4444
spec:
4545
description: 'Spec contains specification of the ProvisioningRequest object.
46-
More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.'
46+
More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.
47+
The spec is immutable, to make changes to the request users are expected
48+
to delete an existing and create a new object with the corrected fields.'
4749
properties:
48-
additionalParameters:
50+
parameters:
4951
additionalProperties:
52+
description: Parameter is limited to 255 characters.
53+
maxLength: 255
5054
type: string
51-
description: AdditionalParameters contains all other parameters custom
52-
classes may require.
55+
description: Parameters contains all other parameters classes may
56+
require. 'atomic-scale-up.kubernetes.io' supports 'ValidUntilSeconds'
57+
parameter, which should contain a string denoting duration for which
58+
we should retry (measured since creation fo the CR).
59+
maxProperties: 100
5360
type: object
5461
x-kubernetes-validations:
5562
- message: Value is immutable
@@ -65,7 +72,6 @@ spec:
6572
description: Count contains the number of pods that will be
6673
created with a given template.
6774
format: int32
68-
maximum: 16384
6975
minimum: 1
7076
type: integer
7177
podTemplateRef:
@@ -79,6 +85,8 @@ spec:
7985
name:
8086
description: 'Name of the referenced object. More info:
8187
https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names'
88+
maxLength: 253
89+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
8290
type: string
8391
type: object
8492
required:
@@ -91,32 +99,38 @@ spec:
9199
x-kubernetes-validations:
92100
- message: Value is immutable
93101
rule: self == oldSelf
94-
provisioningClass:
95-
description: 'ProvisioningClass describes the different modes of provisioning
96-
the resources. Supported values: * check-capacity.kubernetes.io
102+
provisioningClassName:
103+
description: 'ProvisioningClassName describes the different modes
104+
of provisioning the resources. Currently there is no support for
105+
''ProvisioningClass'' objects. Supported values: * check-capacity.kubernetes.io
97106
- check if current cluster state can fullfil this request, do not
98-
reserve the capacity. * atomic-scale-up.kubernetes.io - provision
99-
the resources in an atomic manner * ... - potential other classes
100-
that are specific to the cloud providers'
107+
reserve the capacity. Users should provide a reference to a valid
108+
PodTemplate object. CA will check if there is enough capacity in
109+
cluster to fulfill the request and put the answer in ''CapacityAvailable''
110+
condition. * atomic-scale-up.kubernetes.io - provision the resources
111+
in an atomic manner. Users should provide a reference to a valid
112+
PodTemplate object. CA will try to create the VMs in an atomic manner,
113+
clean any partially provisioned VMs and re-try the operation in
114+
a exponential back-off manner. Users can configure the timeout duration
115+
after which the request will fail by ''ValidUntilSeconds'' key in
116+
''Parameters''. CA will set ''Failed=true'' or ''Provisioned=true''
117+
condition according to the outcome. * ... - potential other classes
118+
that are specific to the cloud providers. ''kubernetes.io'' suffix
119+
is reserved for the modes defined in Kubernetes projects.'
120+
maxLength: 253
121+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
101122
type: string
102123
x-kubernetes-validations:
103124
- message: Value is immutable
104125
rule: self == oldSelf
105126
required:
106127
- podSets
107-
- provisioningClass
128+
- provisioningClassName
108129
type: object
109130
status:
110131
description: Status of the ProvisioningRequest. CA constantly reconciles
111132
this field.
112133
properties:
113-
additionalStatus:
114-
additionalProperties:
115-
type: string
116-
description: AdditionalStatus contains all other status values custom
117-
provisioning classes may require.
118-
minProperties: 64
119-
type: object
120134
conditions:
121135
description: Conditions represent the observations of a Provisioning
122136
Request's current state. Those will contain information whether
@@ -192,6 +206,15 @@ spec:
192206
x-kubernetes-list-map-keys:
193207
- type
194208
x-kubernetes-list-type: map
209+
provisioningClassDetails:
210+
additionalProperties:
211+
description: Detail is limited to 32768 characters.
212+
maxLength: 32768
213+
type: string
214+
description: ProvisioningClassDetails contains all other values custom
215+
provisioning classes may want to pass to end users.
216+
maxProperties: 64
217+
type: object
195218
type: object
196219
required:
197220
- spec

cluster-autoscaler/hack/update-codegen.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ chmod +x "${CODEGEN_PKG}"/generate-groups.sh
3030
chmod +x "${CODEGEN_PKG}"/generate-internal-groups.sh
3131

3232
bash "${CODEGEN_PKG}"/generate-groups.sh "applyconfiguration,client,deepcopy,informer,lister" \
33-
k8s.io/autoscaler/cluster-autoscaler/provisioningrequests/client \
34-
k8s.io/autoscaler/cluster-autoscaler/provisioningrequests/apis \
33+
k8s.io/autoscaler/cluster-autoscaler/provisioningrequest/client \
34+
k8s.io/autoscaler/cluster-autoscaler/provisioningrequest/apis \
3535
autoscaling.x-k8s.io:v1beta1 \
3636
--go-header-file "${SCRIPT_ROOT}"/../hack/boilerplate/boilerplate.generatego.txt
3737

cluster-autoscaler/proposals/provisioning-request.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ type ProvisioningRequestSpec struct {
9797
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
9898
ProvisioningClass string `json:"provisioningClass"`
9999

100-
// AdditionalParameters contains all other parameters custom classes may require.
100+
// Parameters contains all other parameters custom classes may require.
101101
//
102102
// +optional
103103
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
104-
AdditionalParameters map[string]string `json:"additionalParameters"`
104+
Parameters map[string]string `json:"Parameters"`
105105
}
106106

107107
type PodSet struct {
@@ -142,11 +142,11 @@ type ProvisioningRequestStatus struct {
142142
// +optional
143143
Conditions []metav1.Condition `json:"conditions"`
144144

145-
// AdditionalStatus contains all other status values custom provisioning classes may require.
145+
// Statuses contains all other status values custom provisioning classes may require.
146146
//
147147
// +optional
148148
// +kubebuilder:validation:MaxItems=64
149-
AdditionalStatus map[string]string `json:"additionalStatus"`
149+
Statuses map[string]string `json:"statuses"`
150150
}
151151
```
152152

@@ -168,7 +168,7 @@ specified pods in an atomic way. The proposed logic is to:
168168
1. Try to provision required VMs in one loop.
169169
2. If it failed, remove the partially provisioned VMs and back-off.
170170
3. Stop the back-off after a given duration (optional), which would be passed
171-
via `AdditionalParameters` field, using `ValidUntilSeconds` key and would contain string
171+
via `Parameters` field, using `ValidUntilSeconds` key and would contain string
172172
denoting duration for which we should retry (measured since creation fo the CR).
173173

174174
Note: that the VMs created in this mode are subject to the scale-down logic.
@@ -318,9 +318,9 @@ type ProvisioningClass struct {
318318
// +kubebuilder:validation:Required
319319
Name string `json:"name"`
320320

321-
// AdditionalParameters contains all other parameters custom classes may require.
321+
// Parameters contains all other parameters custom classes may require.
322322
//
323323
// +optional
324-
AdditionalParameters map[string]string `json:"additionalParameters"`
324+
Parameters map[string]string `json:"Parameters"`
325325
}
326326
```

cluster-autoscaler/provisioningrequests/apis/autoscaling.x-k8s.io/v1beta1/types.go renamed to cluster-autoscaler/provisioningrequest/apis/autoscaling.x-k8s.io/v1beta1/types.go

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ type ProvisioningRequest struct {
4646
metav1.ObjectMeta `json:"metadata,omitempty"`
4747
// Spec contains specification of the ProvisioningRequest object.
4848
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.
49+
// The spec is immutable, to make changes to the request users are expected to delete an existing
50+
// and create a new object with the corrected fields.
4951
//
5052
// +kubebuilder:validation:Required
5153
Spec ProvisioningRequestSpec `json:"spec"`
@@ -81,24 +83,42 @@ type ProvisioningRequestSpec struct {
8183
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
8284
PodSets []PodSet `json:"podSets"`
8385

84-
// ProvisioningClass describes the different modes of provisioning the resources.
86+
// ProvisioningClassName describes the different modes of provisioning the resources.
87+
// Currently there is no support for 'ProvisioningClass' objects.
8588
// Supported values:
8689
// * check-capacity.kubernetes.io - check if current cluster state can fullfil this request,
87-
// do not reserve the capacity.
88-
// * atomic-scale-up.kubernetes.io - provision the resources in an atomic manner
89-
// * ... - potential other classes that are specific to the cloud providers
90+
// do not reserve the capacity. Users should provide a reference to a valid PodTemplate object.
91+
// CA will check if there is enough capacity in cluster to fulfill the request and put
92+
// the answer in 'CapacityAvailable' condition.
93+
// * atomic-scale-up.kubernetes.io - provision the resources in an atomic manner.
94+
// Users should provide a reference to a valid PodTemplate object.
95+
// CA will try to create the VMs in an atomic manner, clean any partially provisioned VMs
96+
// and re-try the operation in a exponential back-off manner. Users can configure the timeout
97+
// duration after which the request will fail by 'ValidUntilSeconds' key in 'Parameters'.
98+
// CA will set 'Failed=true' or 'Provisioned=true' condition according to the outcome.
99+
// * ... - potential other classes that are specific to the cloud providers.
100+
// 'kubernetes.io' suffix is reserved for the modes defined in Kubernetes projects.
90101
//
91102
// +kubebuilder:validation:Required
92103
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
93-
ProvisioningClass string `json:"provisioningClass"`
104+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
105+
// +kubebuilder:validation:MaxLength=253
106+
ProvisioningClassName string `json:"provisioningClassName"`
94107

95-
// AdditionalParameters contains all other parameters custom classes may require.
108+
// Parameters contains all other parameters classes may require.
109+
// 'atomic-scale-up.kubernetes.io' supports 'ValidUntilSeconds' parameter, which should contain
110+
// a string denoting duration for which we should retry (measured since creation fo the CR).
96111
//
97112
// +optional
98113
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
99-
AdditionalParameters map[string]string `json:"additionalParameters"`
114+
// +kubebuilder:validation:MaxProperties=100
115+
Parameters map[string]Parameter `json:"parameters"`
100116
}
101117

118+
// Parameter is limited to 255 characters.
119+
// +kubebuilder:validation:MaxLength=255
120+
type Parameter string
121+
102122
// PodSet represents one group of pods for Provisioning Request to provision capacity.
103123
type PodSet struct {
104124
// PodTemplateRef is a reference to a PodTemplate object that is representing pods
@@ -112,7 +132,6 @@ type PodSet struct {
112132
// template.
113133
//
114134
// +kubebuilder:validation:Minimum=1
115-
// +kubebuilder:validation:Maximum=16384
116135
Count int32 `json:"count"`
117136
}
118137

@@ -122,6 +141,8 @@ type Reference struct {
122141
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names
123142
//
124143
// +kubebuilder:validation:Required
144+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
145+
// +kubebuilder:validation:MaxLength=253
125146
Name string `json:"name,omitempty"`
126147
}
127148

@@ -139,13 +160,18 @@ type ProvisioningRequestStatus struct {
139160
// +optional
140161
Conditions []metav1.Condition `json:"conditions"`
141162

142-
// AdditionalStatus contains all other status values custom provisioning classes may require.
163+
// ProvisioningClassDetails contains all other values custom provisioning classes may
164+
// want to pass to end users.
143165
//
144166
// +optional
145-
// +kubebuilder:validation:MinProperties=64
146-
AdditionalStatus map[string]string `json:"additionalStatus"`
167+
// +kubebuilder:validation:MaxProperties=64
168+
ProvisioningClassDetails map[string]Detail `json:"provisioningClassDetails"`
147169
}
148170

171+
// Detail is limited to 32768 characters.
172+
// +kubebuilder:validation:MaxLength=32768
173+
type Detail string
174+
149175
// The following constants list all currently available Conditions Type values.
150176
// See: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Condition
151177
const (

cluster-autoscaler/provisioningrequests/apis/autoscaling.x-k8s.io/v1beta1/zz_generated.deepcopy.go renamed to cluster-autoscaler/provisioningrequest/apis/autoscaling.x-k8s.io/v1beta1/zz_generated.deepcopy.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)