Implement Limit controller - #868
Conversation
e556212 to
0b8d70e
Compare
dlaw4608
left a comment
There was a problem hiding this comment.
Hey Winston, great job on the PR!! , I left a few comments after a quick first look, I am looking into it more but just to show you what I found so far WDYT?
|
Thanks @dlaw4608 for the review. I will fix them. At the same time, I am also trying to figure out the CI failures. |
0b8d70e to
b41c2e4
Compare
|
After further debugging, I found two issues in the CI e2e failures.
Limits can be created successfully.
This makes all limit import related test cases unable to pass in |
3540f8b to
60bb5b3
Compare
|
I added a step in e2e workflow to skip the limit import test cases for openstack versions other than |
winiciusallan
left a comment
There was a problem hiding this comment.
Hey @chenwng, I did a first round of review, but I need to take a look at the rest. Thanks for your PR.
| | group | | ✔ | ✔ | | ||
| | image | ✔ | ✔ | ✔ | | ||
| | keypair | | ◐ | ◐ | | ||
| | limit | | | ◐ | |
There was a problem hiding this comment.
When we have RegionRef on this controller, I believe we will be pretty much done.
There was a problem hiding this comment.
Yes. After Region controller is merged, we can add the RegionRef field.
There was a problem hiding this comment.
We have the Region controller now, we can now add RegionRef. However, don't feel pressured to add support for it in this PR, we can do with a follow-up.
| return nil, progress.WrapError(err) | ||
| } | ||
|
|
||
| logger.Info("limit created", "createOpts", createOpts) |
There was a problem hiding this comment.
Let's remove this. Maybe you have put for debug purposes.
There was a problem hiding this comment.
I added it during debugging the CI issue and it was because I wasn't able to tell if the limit actually was created. And after debugging, I thought given it is informational and helps understand whether the controller is working normally, so I left it.
I understand there are other general places printing logs which would tell whether a resource has been created successfully after reconciling, such as Reconcile successful, but I would argue some concret log confirming it would help better when checking the log for either information only or troubleshooting.
There was a problem hiding this comment.
Let's remove this (it's not consistent with other controller).
Also, if we add logging, we should use the project conventions: https://k-orc.cloud/development/coding-standards/#logging
There was a problem hiding this comment.
I will remove it although I would still suggest adding more necessary log prints at critical locations in general given how frustrated I was when troubleshooting issues from other projects without sufficient logs 😄
| // There seems to be a bug that keystone doesn't clear the description field when receiving a PATCH request with an empty description. | ||
| // This will cause the `Progressing` condition stuck with `Resource status will be refreshed`. | ||
| // Tested with `openstack limit set --description ""` | ||
| handleDescriptionUpdate(&updateOpts, resource, osResource) | ||
| // The same issue exists with resourceLimit. Updating resourceLimit with 0 doesn't work. | ||
| handleResourceLimitUpdate(&updateOpts, resource, osResource) |
There was a problem hiding this comment.
Indeed it looks like something on Keystone's side. Keystone doesn't differentiate description unset and empty string. I think this is something that we could address in upstream if you would like to give it a try.
There was a problem hiding this comment.
Thanks for pointing to the root cause. I am not quite familiar with the implementation of keystone. I will put it in low priority and probably give it a try in the future when I have time.
|
@chenwng FYI, RegisteredLimit has been merged |
|
@gndrmnn thanks. I will update this PR accordingly. |
| | group | | ✔ | ✔ | | ||
| | image | ✔ | ✔ | ✔ | | ||
| | keypair | | ◐ | ◐ | | ||
| | limit | | | ◐ | |
There was a problem hiding this comment.
We have the Region controller now, we can now add RegionRef. However, don't feel pressured to add support for it in this PR, we can do with a follow-up.
|
|
||
| - name: Run e2e tests | ||
| run: | | ||
| if [[ "${{ matrix.name }}" != "gazpacho" ]]; then |
There was a problem hiding this comment.
This seems very fragile. Don't we have a better way to skip tests? Perhaps we need to improve kuttl (in my experience, they're very receptive).
There was a problem hiding this comment.
I was considering using labels, but then it seems I will need to update all cases with labels. If kubettl has something like --skip-labels, it will be a good fit for this case.
| spec: | ||
| containers: | ||
| - name: setup-teardown | ||
| image: ghcr.io/chenwng/orc-helper:latest |
There was a problem hiding this comment.
What is this container image about, why do we need it?
I suspect the cleanup can be executed via CRD operations, like we do in the role tests for example.
Also we can't run an image from a personal registry, especially one tagged with latest for obvious supply chain dependency reasons.
There was a problem hiding this comment.
It was used to create RegisteredLimits during case setup and delete RegisteredLimits and disable Domains during teardown before RegisteredLimit was merged. I will update it since RegisteredLimit has been merged.
We can use steps to do cleanup for things like disabling Domains. However, I suspect in case there is any failure before these cleanup steps, they will not be executed and the Domains will get stuck. Ideally, kuttl should have something like pre-crd/resource-delete step/hook to allow some user cleanup actions which can always run no matter if the case fails or not. I didn't find such a feature in kuttl, or maybe I missed it.
There was a problem hiding this comment.
Agreed that it would be nice if kuttl had something like a cleanup step that runs unconditionally of previous steps success. Another possible enhancement to the project 😉
There was a problem hiding this comment.
Removed the setup/cleanup deployments. I will find some time for the kuttl enhancements for teardown step and --skip-labels.
There was a problem hiding this comment.
fwiw, kuttl maintainers are very receptive and I've been having a good experience. I've been working on this pull request which adds some conditional deletion of resources when a case fail or succeed. You could re-use some of the structures in your enhacements, it'd be nice to have it 😄.
2da7215 to
c089c09
Compare
mandre
left a comment
There was a problem hiding this comment.
LGTM overall. Almost ready to merge.
| // +kubebuilder:validation:XValidation:rule="!(has(self.projectRef) && has(self.domainRef))",message="projectRef and domainRef are mutually exclusive" | ||
| type LimitResourceSpec struct { | ||
| // description is a human-readable description for the resource. | ||
| // Note, currently, there is an issue with keystone that it fails to clear the description field |
There was a problem hiding this comment.
Is the keystone bug proper, or the gophercloud implementation of it (i.e. missing field pointer)? Do we have a bug report?
There was a problem hiding this comment.
It is a bug from keystone. It can be reproduced with openstack cli, so it is not an issue of gophercloud. @winiciusallan has helped locate the issue https://github.com/k-orc/openstack-resource-controller/pull/868/changes#r3707450414 . I haven't reported it yet.
| return nil, progress.WrapError(err) | ||
| } | ||
|
|
||
| logger.Info("limit created", "createOpts", createOpts) |
There was a problem hiding this comment.
Let's remove this (it's not consistent with other controller).
Also, if we add logging, we should use the project conventions: https://k-orc.cloud/development/coding-standards/#logging
| openstack registered limit list --resource-name limit-create-minimal-1 && | ||
| openstack registered limit list --resource-name limit-create-minimal-2 |
There was a problem hiding this comment.
Would you mind explaining why you are listing the registered limits?
There was a problem hiding this comment.
This was from the previous to confirm they have been created successfully before RegisteredLimit controller was merged. Now, we don't need it anymore. I will remove it.
There was a problem hiding this comment.
Oh, so in that case you might want to remove the others as well
edit:
> grep -rn "registered limit list" internal/
internal/controllers/limit/tests/limit-create-full/00-assert.yaml:87: openstack registered limit list --resource-name limit-create-full-1 &&
internal/controllers/limit/tests/limit-create-full/00-assert.yaml:88: openstack registered limit list --resource-name limit-create-full-2
internal/controllers/limit/tests/limit-create-minimal/00-assert.yaml:87: openstack registered limit list --resource-name limit-create-minimal-1 &&
internal/controllers/limit/tests/limit-create-minimal/00-assert.yaml:88: openstack registered limit list --resource-name limit-create-minimal-2
internal/controllers/limit/tests/limit-dependency/01-assert.yaml:100: openstack registered limit list --resource-name limit-dependency-1 &&
internal/controllers/limit/tests/limit-dependency/01-assert.yaml:101: openstack registered limit list --resource-name limit-dependency-2 &&
internal/controllers/limit/tests/limit-dependency/01-assert.yaml:102: openstack registered limit list --resource-name limit-dependency-3
internal/controllers/limit/tests/limit-import-dependency/01-assert.yaml:73: openstack registered limit list --resource-name limit-import-dependency
internal/controllers/limit/tests/limit-import-error/00-assert.yaml:98: openstack registered limit list --resource-name limit-import-error
internal/controllers/limit/tests/limit-import/00-assert.yaml:70: openstack registered limit list --resource-name limit-import &&
internal/controllers/limit/tests/limit-import/00-assert.yaml:71: openstack registered limit list --resource-name limit-import-nonexistent-resource
internal/controllers/limit/tests/limit-update/00-assert.yaml:72: openstack registered limit list --resource-name limit-updateThere was a problem hiding this comment.
@chenwng Just making sure you've seen Winicius' comment above ⬆️
There was a problem hiding this comment.
Thanks. Just removed all of them.
winiciusallan
left a comment
There was a problem hiding this comment.
I'm happy with this. Thanks for your amazing contribution @chenwng!
Before merging, and if this won't bother you, could you squash your commits? There are a few addressing-review commits that might fall into cracks in our history. We usually have:
- One commit with the controller scaffolding, having the run command in its description.
- One or more commits with the implementation itself. Here I believe you can use your best judgement
go run ./cmd/scaffold-controller -interactive=false \
-kind=Limit \
-gophercloud-client=NewIdentityV3 \
-gophercloud-module=github.com/gophercloud/gophercloud/v2/openstack/identity/v3/limits \
-gophercloud-type=Limit \
-openstack-json-object=limit \
-available-polling-period=0 \
-deleting-polling-period=0 \
-required-create-dependency=Service \
-optional-create-dependency=Project \
-optional-create-dependency=Domain \
-import-dependency=Service \
-import-dependency=Project \
-import-dependency=Domain
b114351 to
4b96d4e
Compare
This PR implements the controller for
Limitin Keystone.Close #851