Feat/floatingip - #392
Feat/floatingip#392
Conversation
|
Failed to assess the semver bump. See logs for details. |
mandre
left a comment
There was a problem hiding this comment.
Thanks for the PR! This is great.
Early feedback on the API for now. I haven't looked at the rest yet.
| // portID is the ID of the port to which the floatingip is associated. | ||
| // +kubebuilder:validation:MaxLength=1024 | ||
| // +optional | ||
| PortID *string `json:"portID,omitempty"` |
There was a problem hiding this comment.
This should be a reference to a port rather than an ID, we need to change it to portRef. This allows us to add a dependency on the port and wait for it to be created externally if needed.
We've documented this requirement in the General design considerations, however we should probably make it more obvious by adding it to the General API guidelines too.
| // fixedIP is the IP address of the port to which the floatingip is associated. | ||
| // +optional | ||
| FixedIP *IPvAny `json:"fixedIP,omitempty"` | ||
| } |
There was a problem hiding this comment.
Just a note, not necessary to add it now, we'll need at some point to add a projectRef for the FloatingIP resource as I'm doing in #377.
There was a problem hiding this comment.
Ok, maybe for a next PR 😅
|
Hi @mandre, thanks for the quick feedback. I was going to address the lint issues before I ask for review but I didn't have much time to look at it. I'll go over your comments and lint validations these days. |
It could not rebase your PR due to a conflict: https://github.com/k-orc/openstack-resource-controller/actions/runs/14848877163/job/41688586737?pr=392#step:3:11 You should rebase manually on top of main and fix the conflict. |
|
Failed to assess the semver bump. See logs for details. |
|
You should do a rebase (and not a merge) because go-apidiff rebases your changes and is not able to apply one of them, you need to update it so it applies cleanly on top of main. |
Thanks, looks better now. |
mandre
left a comment
There was a problem hiding this comment.
Still not finished with the review, but I wanted to leave my pending comments before my extended weekend 😃
| cloudName: openstack-admin | ||
| secretName: openstack-clouds | ||
| managementPolicy: managed | ||
| resource: |
There was a problem hiding this comment.
Typically, this test should set all of the fields that we defined in the resource spec to a non-default value. Looks like we're missing some of them.
| metadata: | ||
| name: floating-ip-create-full | ||
| status: | ||
| resource: |
There was a problem hiding this comment.
Please also make sure to check all the fields from status, in particular, we want to ensure we got a floating IP address.
| if resource.SubnetRef != nil { | ||
| { | ||
| // Fetch dependencies and ensure they have our finalizer | ||
| subnet, reconcileStatus := subnetDep.GetDependency( |
There was a problem hiding this comment.
|
I hope I addressed all the comments, although I haven't got time to test it on a real cluster/openstack site yet. I will try to find the time during these days and let you know so you don't review untested code. I will mark the PR as draft for now |
|
Hi @mandre, after some struggle with e2e I believe it's ready for review again. Sorry for the commit spam, but I had to use the workflows you already have in place for deploying devstack as I don't have a local instance of it, and in the one I used for testing I don't have admin credentials. |
mandre
left a comment
There was a problem hiding this comment.
This is really close, we should be able to merge soon. I've got a few more comments, the most important one being for the name of the network reference. I'm not sure if we should call it networkRef, as currently implemented, or floatingNetworkRef to be closer to neutron API.
Before we merge your patch, could you also squash the commits?
What happened to the floatingip-import-error test you had at some point? From what I recall, they were good.
|
|
||
| // networkRef is a reference to the ORC Network which this resource is associated with.l | ||
| // +optional | ||
| NetworkRef KubernetesNameRef `json:"networkRef"` |
There was a problem hiding this comment.
I wonder if we shouldn't call this field FloatingNetworkRef, to align better with the neutron API. @mdbooth, thoughts?
There was a problem hiding this comment.
Agree. It will make it more obvious what it is.
There was a problem hiding this comment.
Also, please make it a pointer, with omitempty marker (wherever the field is optional). It was my mistake originally when I introduced these fields in #302. Changing them now would require a major bump, so let's try not to introduce more of them if we can avoid it.
Same goes for PortRef below.
| const controllerName = "floatingip" | ||
|
|
||
| var ( | ||
| fieldOwner = orcstrings.GetSSAFieldOwner(controllerName) |
There was a problem hiding this comment.
Please use externalObjectFieldOwner variable instead.
| Year string | ||
| Name string | ||
| NameLower string | ||
| IsNotNamed bool |
There was a problem hiding this comment.
I'm not a big fan of new field's name, but I can't come up with a better name. Perhaps we could just make getResourceName() gracefully handle the case where the spec does not have a name instead?
I believe at some moment during the e2e nightmare I decided it was not useful, but now I can't recall why. I'll create it again
About that, I don't have a clear answer, I'm fine with naming it as you prefer.
I can make getResourceName use reflection to detect if the ResourceSpec contains a name or not, I didn't do it this way before as it would be more disruptive, and I believe getResourceName should not be even defined for nameless resources, to make sure we don't use it during reconciliation (otherwise we would need to consider getResourceName to return empty string in multiple places, something that currently can't happen as all named resources will either have Resource.Name or Metadata.Name) func getResourceName(orcObject orcObjectPT) string {
if orcObject.Spec.Resource.Name != nil {
return string(*orcObject.Spec.Resource.Name)
}
return orcObject.Name
} |
done 😄 |
mandre
left a comment
There was a problem hiding this comment.
If you could also improve the commit message, trying to stick to the kubernetes guidelines as much as possible.
|
|
||
| // networkRef is a reference to the ORC Network which this resource is associated with.l | ||
| // +optional | ||
| NetworkRef KubernetesNameRef `json:"networkRef"` |
There was a problem hiding this comment.
Also, please make it a pointer, with omitempty marker (wherever the field is optional). It was my mistake originally when I introduced these fields in #302. Changing them now would require a major bump, so let's try not to introduce more of them if we can avoid it.
Same goes for PortRef below.
| // +optional | ||
| Description *NeutronDescription `json:"description,omitempty"` | ||
|
|
||
| // networkRef is a reference to the ORC Network which this resource is associated with.l |
There was a problem hiding this comment.
Nit: there's a trailing l.
| // networkRef is a reference to the ORC Network which this resource is associated with.l | |
| // networkRef is a reference to the ORC Network which this resource is associated with. |
|
|
||
| // subnetRef references the subnet to which the floatingip is associated. | ||
| // +optional | ||
| SubnetRef *KubernetesNameRef `json:"subnetRef,omitempty"` |
There was a problem hiding this comment.
Indeed, after I it a bit more thoughts, I believe these fields should be called FloatingNetworkRef and FloatingSubnetRef.
Also, @mdbooth raised a good point yesterday. We should make FloatingNetworkRef and FloatingSubnetRef mutually exclusive, with exactly one being set, because a subnet always has a network, and letting users set a network at the same time as the subnet is only a potential source of error.
I think the following validation enforces it:
// +kubebuilder:validation:XValidation:rule="has(self.floatingNetworkRef) != has(self.floatingSubnetRef)",message="Exactly one of 'floatingNetworkRef' or 'floatingSubnetRef' must be set"
sorry, I didn't notice the squashed commits remained. Will do |
|
@mandre I believe all comments were addressed (I hope I didn't miss anyone).
Please let me know if you believe I should change something related to this template. Related to
I added one more test called |
Nah, it's alright. We don't expose it as an API so we can easily change it later if we don't like it.
Good call. Let's get this merged :) |
Floating IP controller was implemented in k-orc#392.
Floating IP controller was implemented in k-orc#392.
Implement FloatingIP controller/actuator