Keystone: Implement RegisteredLimit Controller - #782
Conversation
|
Failed to assess the semver bump. See logs for details. |
22a08f7 to
e46ac56
Compare
e46ac56 to
4964e1d
Compare
8379469 to
027f4aa
Compare
b6de206 to
e46d4a0
Compare
4c2f1fe to
8c90198
Compare
|
Hi, this PR is more or less good to be reviewed. I am currently running into a strange problem though: In the I have already setup a local keystone instance to test this against, and I can not reproduce the What makes this especially weird is, I have looked at the |
Hi @gndrmnn, I won't be able to look at this right away. Perhaps @eshulman2, @dlaw4608, or @winiciusallan can do a first round of reviews, and might have ideas on what could be causing the tests to fail. I'll look at this when I'm back. |
winiciusallan
left a comment
There was a problem hiding this comment.
Hi @gndrmnn, try the suggestion and let's see how the tests behave. In the meantime, I'll review the rest of your code. Thanks for working on this.
$ go run ./cmd/scaffold-controller -interactive=false \
-kind=RegisteredLimit \
-gophercloud-client=NewIdentityV3 \
-gophercloud-module=github.com/gophercloud/gophercloud/v2/openstack/identity/v3/registeredlimits \
-gophercloud-type=RegisteredLimit \
-openstack-json-object=registered_limits \
-required-create-dependency=Service \
-import-dependency=Service
On-behalf-of: SAP nils.gondermann@sap.com
Register with the resource generator On-behalf-of: SAP nils.gondermann@sap.com
Add the OpenStack client to scope On-behalf-of: SAP nils.gondermann@sap.com
Register the controller On-behalf-of: SAP nils.gondermann@sap.com
On-behalf-of: SAP nils.gondermann@sap.com
85d8901 to
1221836
Compare
On-behalf-of: SAP nils.gondermann@sap.com
1221836 to
7ba4ab5
Compare
dlaw4608
left a comment
There was a problem hiding this comment.
Looks Good, currently going through the E2E tests, also don't forget to add this controller the the README
| // TODO(scaffolding): Add more fields | ||
| ServiceID: serviceID, | ||
| ResourceName: resource.ResourceName, | ||
| DefaultLimit: int(*resource.DefaultLimit), |
There was a problem hiding this comment.
I'm afraid that we have a bug in Gophercloud: we can't use the default limit as 0. Have you tested this in one of your runs?
There was a problem hiding this comment.
I can confirm a default value of 0 will cause a invalid configuration creating resource error. defaultLimit is required in Gophercloud, but a zero value will fail validation.
There was a problem hiding this comment.
There was a problem hiding this comment.
It only seems to be affecting creation, because the field in UpdateOpts doesn't have the required:true marker.
So let's return a terminal error here when DefaultLimit is 0, pointing to the gophercloud bug.
7ba4ab5 to
77b0b7a
Compare
On-behalf-of: SAP nils.gondermann@sap.com
On-behalf-of: SAP nils.gondermann@sap.com
Generate the OLM bundle On-behalf-of: SAP nils.gondermann@sap.com
77b0b7a to
6147781
Compare
On-behalf-of: SAP nils.gondermann@sap.com
6147781 to
d5b3186
Compare
mandre
left a comment
There was a problem hiding this comment.
Again, this looks very good. Just a few cleanup needed before we can merge it.
| // +kubebuilder:validation:MaxLength:=255 | ||
| // +required | ||
| // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="resourceName is immutable" | ||
| ResourceName string `json:"resourceName,omitempty"` |
There was a problem hiding this comment.
It looks like keystone enforces names with non-whitespaces chars only:
name: dict[str, Any] = {
"type": "string",
"minLength": 1,
"maxLength": 255,
"pattern": r"[\S]+",
"description": "The resource name.",
}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.
| // +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. |
There was a problem hiding this comment.
Should we perhaps explain that -1 means unlimited (no quota), while 0 means hard blocking the usage of this resource? It's easy to wrongly assume that 0 means unlimited.
There was a problem hiding this comment.
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.
| // TODO(scaffolding): Add more fields | ||
| ServiceID: serviceID, | ||
| ResourceName: resource.ResourceName, | ||
| DefaultLimit: int(*resource.DefaultLimit), |
There was a problem hiding this comment.
It only seems to be affecting creation, because the field in UpdateOpts doesn't have the required:true marker.
So let's return a terminal error here when DefaultLimit is 0, pointing to the gophercloud bug.
| return nil, err | ||
| } | ||
|
|
||
| return &batch[0], nil |
There was a problem hiding this comment.
There's no guarantee that the slice is non-empty when err == nil, we should check for len(batch) == 0 and return an error if that's the case.
| // +optional | ||
| RegionID string `json:"regionID,omitempty"` | ||
|
|
||
| // serviceID is a reference to the ORC Service which this resource is associated with. |
There was a problem hiding this comment.
Copy & paste error I assume :)
It should be
| // serviceID is a reference to the ORC Service which this resource is associated with. | |
| // serviceID is the UUID of the service to which the registered limit belongs. |
WIP
RegionIDas k-orc does not have that resource currentlyResourceName,RegionID, andDefaultValueleading to some interesting challengens. E.g. Declaring two yaml files with twoRegisteredLimitswith the sameRegionIDandResourceNamewill race to change the same entry.