Skip to content
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

⚠️ OpenStackCluster api general cleanup #1930

Merged

Conversation

mdbooth
Copy link
Contributor

@mdbooth mdbooth commented Mar 6, 2024

Interestingly, this PR introduces no substantial changes to the CRDs. It primarily affects Go marshalling and documentation. The changes are mostly mechanical.

The PR should hopefully be simpler to review by commit.

The first 2 commits are preparatory, and slightly separate to the other commits. They add some new functionality to the pkg/utils/optional types and update the existing PortOpts to use that functionality.

The rest are structed as changes to single fields, or related sets of fields.

/hold

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 6, 2024
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 6, 2024
Copy link

netlify bot commented Mar 6, 2024

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit e6a194b
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/65eb937ecee527000817deb6
😎 Deploy Preview https://deploy-preview-1930--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdbooth mdbooth force-pushed the openstackcluster_apicleanup branch 2 times, most recently from 72e6ad0 to 74510ef Compare March 7, 2024 16:55
@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 7, 2024

This adds a fix for the externalNetwork issue which was causing CI failures. The issue was CI is emitting the following in the cluster spec:

  spec:
    externalNetwork:
      id: null

The previous logic in ReconcileExternalNetwork correctly treated this as an empty stanza and executed the fallback 'list all external networks' query. The new logic which failed treated this as an explicitly given empty external network filter and executed it, returning all networks including non-external networks. This was an error as there were more than one.

The principal problem here is that we were executing an external network query without the external flag. This is fixed by setting it for both kinds of query (explicit and implicit).

Separately I have also opened #1932 to fix the weird external network stanza in the CI templates.

@mdbooth mdbooth force-pushed the openstackcluster_apicleanup branch 2 times, most recently from cec64a2 to 08beb1d Compare March 8, 2024 17:05
This makes the behaviour slightly more ergonomic and safer as we turn
these into pointers.
This improves safety and ergonomics checking it when NetworkFilter can be be a
pointer type.
For non-mergeable list types, make the default 'atomic' behaviour
explicit.
ExternalNetwork was already marked optional. This change allows it to be
omitted when marshalling and unmarshalling the object in Go.

This change also adds the 'external' flag when executing an explicit
external network query.
…rPort->optional

Affects go marshalling only.
The following types become a corresponding optional type:
* NetworkMTU
* DisableExternalNetwork
* DisableAPIServerFloatingIP
* DisablePortSecurity
* ControlPlaneOmitAvailabilityZone
@mdbooth mdbooth force-pushed the openstackcluster_apicleanup branch from 08beb1d to e6a194b Compare March 8, 2024 22:38
@EmilienM
Copy link
Contributor

EmilienM commented Mar 9, 2024

/test pull-cluster-api-provider-openstack-e2e-full-test


loadBalancerName := getLoadBalancerName(clusterName)
s.scope.Logger().Info("Reconciling load balancer member", "loadBalancerName", loadBalancerName)

lbID := openStackCluster.Status.APIServerLoadBalancer.ID
portList := []int{int(openStackCluster.Spec.ControlPlaneEndpoint.Port)}
var portList []int
if openStackCluster.Spec.ControlPlaneEndpoint != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need the if since we already checked for it at L521?
I guess it's ok. Just in case it was a leftover.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but I've done similar in a few places. In my first pass at this I didn't double-check any pointers, but after hitting a few panics in various iterations I've decided to err on the side of pretty much always checking. Apart from anything else, this is safer against future cut and paste, where somebody might move either use such that one or the other is no longer guarded.

I'd prefer to fix this through the type system, but I'm not having much joy with that today: https://hachyderm.io/@mattb/112077588227331296

@EmilienM
Copy link
Contributor

EmilienM commented Mar 9, 2024

I've reviewed the commits one by one as suggested and everything looks good to me. I have a minor comment inline, but I think this PR is good to go. Thanks for this huge work!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 9, 2024
@huxcrux
Copy link
Contributor

huxcrux commented Mar 11, 2024

This looks good /lgtm

@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 11, 2024

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 11, 2024
@k8s-ci-robot k8s-ci-robot merged commit 8d70c19 into kubernetes-sigs:main Mar 11, 2024
10 checks passed
@mdbooth mdbooth deleted the openstackcluster_apicleanup branch March 11, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants