Skip to content

Keystone: Implement RegisteredLimit Controller - #782

Open
gndrmnn wants to merge 10 commits into
k-orc:mainfrom
gndrmnn:implement_registeredlimit
Open

Keystone: Implement RegisteredLimit Controller#782
gndrmnn wants to merge 10 commits into
k-orc:mainfrom
gndrmnn:implement_registeredlimit

Conversation

@gndrmnn

@gndrmnn gndrmnn commented May 11, 2026

Copy link
Copy Markdown
Contributor

WIP

  • No support for RegionID as k-orc does not have that resource currently
  • RegisteredLimits are unnamed, but have a unique constraint over ResourceName, RegionID, and DefaultValue leading to some interesting challengens. E.g. Declaring two yaml files with two RegisteredLimits with the same RegionID and ResourceName will race to change the same entry.

@github-actions

Copy link
Copy Markdown

Failed to assess the semver bump. See logs for details.

@gndrmnn
gndrmnn force-pushed the implement_registeredlimit branch from 22a08f7 to e46ac56 Compare May 12, 2026 14:31
@github-actions github-actions Bot added the semver:major Breaking change label May 12, 2026
@gndrmnn
gndrmnn force-pushed the implement_registeredlimit branch from e46ac56 to 4964e1d Compare May 13, 2026 13:40
@gndrmnn
gndrmnn force-pushed the implement_registeredlimit branch 4 times, most recently from 8379469 to 027f4aa Compare June 1, 2026 14:23
@gndrmnn
gndrmnn force-pushed the implement_registeredlimit branch 4 times, most recently from b6de206 to e46d4a0 Compare June 29, 2026 14:10
@gndrmnn
gndrmnn force-pushed the implement_registeredlimit branch 11 times, most recently from 4c2f1fe to 8c90198 Compare July 14, 2026 12:02
@gndrmnn

gndrmnn commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@mandre

Hi, this PR is more or less good to be reviewed. I am currently running into a strange problem though: In the registeredlimit-import test we are creating a mandatory Service to use in the import filter. In some cases, the CI pipeline will fail with Waiting for service/<service name> to be ready. Other times, it successfully proceeds to Waiting for OpenStack resource to be created externally. As you can see right now, two CI tests failed while the epoxy one passed.

I have already setup a local keystone instance to test this against, and I can not reproduce the Waiting for service/<service name> to be ready problem. So it looks like this is some kind of timing problem in the test maybe?

What makes this especially weird is, I have looked at the Endpoint actuator and used it as inspiration for this PR. The Endpoint also requires a mandatory ServiceRef and even declares it the same way as I do in the endpoint-import CI test. That test however does not flap at all. So I seem to be doing something wrong, I can not put my finger on right now.

@gndrmnn
gndrmnn marked this pull request as ready for review July 15, 2026 07:02
@mandre

mandre commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

@mandre

Hi, this PR is more or less good to be reviewed. I am currently running into a strange problem though: In the registeredlimit-import test we are creating a mandatory Service to use in the import filter. In some cases, the CI pipeline will fail with Waiting for service/<service name> to be ready. Other times, it successfully proceeds to Waiting for OpenStack resource to be created externally. As you can see right now, two CI tests failed while the epoxy one passed.

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 winiciusallan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/controllers/registeredlimit/controller.go
@gndrmnn
gndrmnn marked this pull request as draft July 20, 2026 07:09
@chenwng chenwng mentioned this pull request Jul 20, 2026
$ 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
gndrmnn added 4 commits July 20, 2026 11:30
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
@gndrmnn
gndrmnn force-pushed the implement_registeredlimit branch 2 times, most recently from 85d8901 to 1221836 Compare July 20, 2026 10:32
On-behalf-of: SAP nils.gondermann@sap.com
@gndrmnn
gndrmnn force-pushed the implement_registeredlimit branch from 1221836 to 7ba4ab5 Compare July 20, 2026 11:04
@gndrmnn
gndrmnn marked this pull request as ready for review July 20, 2026 11:33
@gndrmnn
gndrmnn requested a review from winiciusallan July 20, 2026 11:33

@dlaw4608 dlaw4608 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good, currently going through the E2E tests, also don't forget to add this controller the the README

Comment thread internal/controllers/registeredlimit/status.go
Comment thread api/v1alpha1/registeredlimit_types.go
Comment thread internal/controllers/registeredlimit/actuator.go Outdated
// TODO(scaffolding): Add more fields
ServiceID: serviceID,
ResourceName: resource.ResourceName,
DefaultLimit: int(*resource.DefaultLimit),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this @gndrmnn

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gndrmnn
gndrmnn force-pushed the implement_registeredlimit branch from 7ba4ab5 to 77b0b7a Compare July 21, 2026 10:18
gndrmnn added 3 commits July 22, 2026 09:19
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
@gndrmnn
gndrmnn force-pushed the implement_registeredlimit branch from 77b0b7a to 6147781 Compare July 22, 2026 07:20
On-behalf-of: SAP nils.gondermann@sap.com

@mandre mandre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"`

Copy link
Copy Markdown
Collaborator

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:

name: dict[str, Any] = {
    "type": "string",
    "minLength": 1,
    "maxLength": 255,
    "pattern": r"[\S]+",
    "description": "The resource name.",
}

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.

// +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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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.

// TODO(scaffolding): Add more fields
ServiceID: serviceID,
ResourceName: resource.ResourceName,
DefaultLimit: int(*resource.DefaultLimit),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy & paste error I assume :)
It should be

Suggested change
// 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:major Breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants