-
Notifications
You must be signed in to change notification settings - Fork 261
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
⚠️ Store []ResolvedPortSpec in ReferencedMachineResources #1951
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mdbooth The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
/test pull-cluster-api-provider-openstack-e2e-full-test |
e8507e0
to
8281e5a
Compare
/test pull-cluster-api-provider-openstack-e2e-full-test |
/test pull-cluster-api-provider-openstack-e2e-full-test |
1 similar comment
/test pull-cluster-api-provider-openstack-e2e-full-test |
/test pull-cluster-api-provider-openstack-e2e-full-test |
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.
Comments inline, most of them are more of a question thank a remark.
@@ -6626,6 +6430,10 @@ spec: | |||
implementations. What type of vNIC is actually available depends on | |||
deployments. If not specified, the Neutron default value is used. | |||
type: string | |||
required: | |||
- description |
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 think this sucks that description is required, but if it's to change in a later patch I'm okay.
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.
This is the resolved port spec in the status, which will always have a description: if it didn't have a description we would have generated one. This is expected.
config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml
Outdated
Show resolved
Hide resolved
} | ||
return normalizedPorts, nil | ||
} | ||
|
||
// normalizePortTarget ensures that the port has a network ID. |
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 think all below should be double-checked by @MaysaMacedo. It looks right to me from dual stack perspective, but this is the delicate part in this PR.
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 should be just code motion with changes for context. I didn't intentionally change the logic here.
/test pull-cluster-api-provider-openstack-e2e-full-test |
@dulek Comments addressed. |
Nothing obvious, could be a flake. |
/test pull-cluster-api-provider-openstack-e2e-full-test |
/test pull-cluster-api-provider-openstack-e2e-full-test Error was:
That's not very illuminating! Lets see if it was a flake. |
Same error. |
The purpose of this change is fix an issue where we are storing unresolved references in ReferencedMachineResources. Specifically we are storing a PortOpts, which is a user-intent struct. PortOpts can contain unresolved references to both subnets and security groups, as well fields requiring additional processing which reference external objects: the port name, description, and tags. We create a new type, ResolvedPortSpec, which can contain only fully resolved data. This can be seen in the new signature of CreatePorts(), which no longer requires any source of data other than the []ResolvedPortSpec from ReferencedMachineResources, and is now greatly simplified. Fully resolving the port name also allows a simplification in port adoption. All of the complexity now moves to ConstructPorts(), which is updated to return []ResolvedPortSpec instead of []PortOpts. ConstructPorts() is updated to resolve security groups, port name, description, and all subnets referenced in FixedIPs.
/test pull-cluster-api-provider-openstack-e2e-full-test |
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 looked thru the code and think it looks good. Only one inline comment regarding the function clusterName that actually returns a name used for resources and is not the cluster name.
It can safely be ignored however may cause confusion for someone reading the code. When I see clusterName i almost every time ask myself why cluster.Name is not used since cluster exists almost everywhere already
pkg/utils/names/names.go
Outdated
@@ -36,3 +38,7 @@ func GetFloatingAddressClaimName(openStackMachineName string) string { | |||
func GetOpenStackMachineNameFromClaimName(claimName string) string { | |||
return strings.TrimSuffix(claimName, fmt.Sprintf("-%s", FloatingAddressIPClaimNameSuffix)) | |||
} | |||
|
|||
func ClusterName(cluster *clusterv1.Cluster) string { |
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.
Maybe we should call this variable something else? I get this is used for a lot of resources however it is not the clusters name.
Maybe clusterResourceName or something could work?
I really like the initiative to move this to a function since the name are present in a lot of places in 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.
That's a good point, and I agree. Confusion from this was also the cause of a bug in @EmilienM's ports series a few weeks back that took both of us working together over a day to track down. I think it's worth picking a better name.
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've pushed a separate commit which changes it everywhere. Note that clusterName
in the e2e tests actually does mean cluster name, so I haven't changed it there.
Actually we just broke the upgrade test with a search and replace the other day. Do I learn nothing? 🤦 |
/test pull-cluster-api-provider-openstack-e2e-full-test |
/lgtm Lets hope the full e2e test passes 🤞 |
Passed! /hold cancel |
The purpose of this change is fix an issue where we are storing unresolved references in ReferencedMachineResources. Specifically we are storing a PortOpts, which is a user-intent struct. PortOpts can contain unresolved references to both subnets and security groups, as well fields requiring additional processing which reference external objects: the port name, description, and tags.
We create a new type, ResolvedPortSpec, which can contain only fully resolved data. This can be seen in the new signature of CreatePorts(), which no longer requires any source of data other than the []ResolvedPortSpec from ReferencedMachineResources, and is now greatly simplified.
Fully resolving the port name also allows a simplification in port adoption.
All of the complexity now moves to ConstructPorts(), which is updated to return []ResolvedPortSpec instead of []PortOpts. ConstructPorts() is updated to resolve security groups, port name, description, and all subnets referenced in FixedIPs.
Fixes: #1943
TODO:
/hold