-
Notifications
You must be signed in to change notification settings - Fork 51
Keystone: Implement RegisteredLimit Controller #782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6c902cc
a9cffb5
83e8d40
17e8b9d
7191209
20e2cbb
3c224e0
e5d3ef4
fd45397
d5b3186
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,92 @@ | ||||||
| /* | ||||||
| Copyright The ORC Authors. | ||||||
|
|
||||||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
| you may not use this file except in compliance with the License. | ||||||
| You may obtain a copy of the License at | ||||||
|
|
||||||
| http://www.apache.org/licenses/LICENSE-2.0 | ||||||
|
|
||||||
| Unless required by applicable law or agreed to in writing, software | ||||||
| distributed under the License is distributed on an "AS IS" BASIS, | ||||||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
| See the License for the specific language governing permissions and | ||||||
| limitations under the License. | ||||||
| */ | ||||||
|
|
||||||
| package v1alpha1 | ||||||
|
|
||||||
| // RegisteredLimitResourceSpec contains the desired state of the resource. | ||||||
| type RegisteredLimitResourceSpec struct { | ||||||
| // description is a human-readable description for the resource. | ||||||
| // +kubebuilder:validation:MinLength:=1 | ||||||
| // +kubebuilder:validation:MaxLength:=255 | ||||||
| // +optional | ||||||
| Description *string `json:"description,omitempty"` | ||||||
|
|
||||||
| // serviceRef is a reference to the ORC Service which this resource is associated with. | ||||||
| // +required | ||||||
| // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="serviceRef is immutable" | ||||||
| ServiceRef KubernetesNameRef `json:"serviceRef,omitempty"` | ||||||
|
|
||||||
| // resourceName is name of the resource to be limited. | ||||||
| // +kubebuilder:validation:MinLength:=1 | ||||||
| // +kubebuilder:validation:MaxLength:=255 | ||||||
| // +required | ||||||
| // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="resourceName is immutable" | ||||||
| ResourceName string `json:"resourceName,omitempty"` | ||||||
|
|
||||||
| // defaultLimit is limit of the specified resource in the given context. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we perhaps explain that
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also note the limitation of setting 0 at creation pointing to the gophercloud issue. It seems we can't reliably write a CEL validation that would prevent that (we need the CRDValidationRatcheting gate that's only enabled by default starting from kube 1.30, and we target 1.29 as our floor version). So we would need to add a check in the actuator, at resource creation. |
||||||
| // +kubebuilder:validation:Minimum=-1 | ||||||
| // +kubebuilder:validation:Maximum=2147483647 | ||||||
| // +required | ||||||
| DefaultLimit *int32 `json:"defaultLimit,omitempty"` | ||||||
| } | ||||||
|
|
||||||
| // RegisteredLimitFilter defines an existing resource by its properties | ||||||
| // +kubebuilder:validation:MinProperties:=1 | ||||||
| type RegisteredLimitFilter struct { | ||||||
| // description of the existing resource | ||||||
| // +kubebuilder:validation:MinLength:=1 | ||||||
| // +kubebuilder:validation:MaxLength:=255 | ||||||
| // +optional | ||||||
| Description *string `json:"description,omitempty"` | ||||||
|
gndrmnn marked this conversation as resolved.
|
||||||
|
|
||||||
| // serviceRef is a reference to the ORC Service which this resource is associated with. | ||||||
| // +optional | ||||||
| ServiceRef *KubernetesNameRef `json:"serviceRef,omitempty"` | ||||||
|
|
||||||
| // resourceName is name of the resource to be limited. | ||||||
| // +kubebuilder:validation:MinLength:=1 | ||||||
| // +kubebuilder:validation:MaxLength:=255 | ||||||
| // +optional | ||||||
| ResourceName *string `json:"resourceName,omitempty"` | ||||||
| } | ||||||
|
|
||||||
| // RegisteredLimitResourceStatus represents the observed state of the resource. | ||||||
| type RegisteredLimitResourceStatus struct { | ||||||
| // description is a human-readable description for the resource. | ||||||
| // +kubebuilder:validation:MaxLength=1024 | ||||||
| // +optional | ||||||
| Description string `json:"description,omitempty"` | ||||||
|
|
||||||
| // resourceName is name of the resource to be limited. | ||||||
| // +kubebuilder:validation:MinLength:=1 | ||||||
| // +kubebuilder:validation:MaxLength:=255 | ||||||
| // +optional | ||||||
| ResourceName string `json:"resourceName,omitempty"` | ||||||
|
|
||||||
| // regionID is the ID of the region that contains the service endpoint. | ||||||
| // +kubebuilder:validation:MaxLength:=1024 | ||||||
| // +optional | ||||||
| RegionID string `json:"regionID,omitempty"` | ||||||
|
|
||||||
| // serviceID is a reference to the ORC Service which this resource is associated with. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy & paste error I assume :)
Suggested change
|
||||||
| // +kubebuilder:validation:MaxLength:=1024 | ||||||
| // +optional | ||||||
| ServiceID string `json:"serviceID,omitempty"` | ||||||
|
|
||||||
| // defaultLimit is limit of the specified resource in the given context. | ||||||
| // +optional | ||||||
| DefaultLimit int32 `json:"defaultLimit,omitempty"` | ||||||
| } | ||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like keystone enforces names with non-whitespaces chars only:
https://github.com/openstack/keystone/blob/50d266e/keystone/api/validation/parameter_types.py#L19-L25
We should also have the same validation pattern otherwise we may end up in a situation where we get endless reconciles that can never succeed if someone sets a name with a whitespace.
In other words: our API for resource specs can be stricter than the OpenStack API, never the other way around.