-
Notifications
You must be signed in to change notification settings - Fork 33
Add Trunk resource controller implementation #581
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?
Conversation
winiciusallan
left a comment
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.
Hi, @aldokimi! I've left a few comments in the API types. Thanks for submitting this pull request, it will be very important in achieving parity with CAPO.
api/v1alpha1/trunk_type.go
Outdated
| type Subport struct { | ||
| // portRef is a reference to the ORC Port which will be used as a subport. | ||
| // +required | ||
| PortRef KubernetesNameRef `json:"portRef"` |
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.
| PortRef KubernetesNameRef `json:"portRef"` | |
| PortRef KubernetesNameRef `json:"portRef,omitempty"` |
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.
ack.
api/v1alpha1/trunk_type.go
Outdated
| PortID string `json:"portID,omitempty"` | ||
|
|
||
| // segmentationType is the type of segmentation used. | ||
| // +kubebuilder:validation:MaxLength=1024 |
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.
I believe this should match the same validation in spec for this field.
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's OK if it's higher in the Status than in the Spec (the opposite is not OK).
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.
ack.
mandre
left a comment
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.
I suspect you haven't used the scaffolding tool. If it's not too much trouble, would it be possible for you to re-work your controller to use it? It ensures consistency with the other controllers and makes it much easier for reviewers to see your modifications, since there's typically a lot of boilerplate code in PRs for new controllers. See #568 (comment) for the rational. I'm currently working on updating the developers doc to make it more obvious.
I bet it was a lot of work to contribute this controller without the help of the scaffolding tool, so if that turns out to be too complicated to rework your change to make use of it, I'm ready to make an exception.
FYI, here's how I expect us to run the scaffolding tool, based on what the resource supports:
go run ./cmd/scaffold-controller \
-interactive=false \
-kind Trunk \
-gophercloud-client NewNetworkV2 \
-gophercloud-module github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/trunks \
-import-dependency Port \
-import-dependency Project \
-optional-create-dependency Project \
-required-create-dependency Port
api/v1alpha1/trunk_type.go
Outdated
| PortID string `json:"portID,omitempty"` | ||
|
|
||
| // segmentationType is the type of segmentation used. | ||
| // +kubebuilder:validation:MaxLength=1024 |
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's OK if it's higher in the Status than in the Spec (the opposite is not OK).
ae0d632 to
b1f5243
Compare
|
Failed to assess the semver bump. See logs for details. |
winiciusallan
left a comment
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.
Hey @aldokimi, I've left more comments. This kind of PR tends to be very large, so I'll need to take another look. But for now, thanks for addressing the comments. =D
cmd/resource-generator/main.go
Outdated
| }, | ||
| { | ||
| Name: "Trunk", | ||
| ExistingOSClient: true, |
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.
Could you please remove this field? This uses an existing client, but we want to separate clients for each controller.
You may remove and run make generate. Maybe do you need to refactor other parts along the code.
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.
ack.
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.
But I don't really understand why removing this field is necessary, could elaborate more please?
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.
Good question. To be honest, I don't know the exactly reason. I believe @mandre can explain it better.
My guess is, if you need some extra logic for a specific client, you won't impact the others implemented in the same interface. As I said, is just I guess, so don't take it as the truth 😅.
| return nil | ||
| } | ||
|
|
||
| updateOpts.RevisionNumber = &osResource.RevisionNumber |
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.
May the revision number be nil, or does the API always returns a valid value?
| yield(nil, err) | ||
| }, nil | ||
| } | ||
| return func(yield func(*osResourceT, error) bool) { |
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.
Same about the comment on ListForAdoption.
internal/controllers/trunk/tests/trunk-create-minimal/00-assert.yaml
Outdated
Show resolved
Hide resolved
b1f5243 to
960bd52
Compare
|
@aldokimi I may be a little busy (resting...) in the next few days, so maybe I'll take a little while to review your commits, but at the start of the year, I should take a look into it. Thanks for contributing, we really appreciate it. =D |
|
Hey @aldokimi, I had some time to take a look into your PR. It looks like you have overrided your old implementation for Trunk types with the code generated by the scaffolding tool. Are you still working on this? Also, I saw that you changed a lot of tests files from other controllers, I believe we don't want to touch another controllers on this pull request. Do you have made this changes for a specific reason? If you are still working on this, you can ignore my comment. Let me know when you believe it is ready for another review :) |
Hello @winiciusallan , I am still going to upload a last commit, the changes on the test files where because of the scaffolding tool, my last commit will be about fixing the issues regarding the scaffolding and then we will be ready for a new review! Thank you for your comment, happy holidays! |
710a752 to
545a5fa
Compare
|
Hello @winiciusallan and @mandre , happy new year! So, I am sorry for this mess, this is the biggest PR of my life xD Thanks, |
Summary
Adds complete Trunk resource controller implementation with subport implementation (which is necessary for the Trunk type), dependency handling, and comprehensive test coverage.
Key Features
Testing
E2E Testing
-All resources are created in the K8s side
-All resources are created in the Openstack side
-All CRUD functionalities are passing the tests
Checklist