Skip to content

Conversation

mdbooth
Copy link
Contributor

@mdbooth mdbooth commented Jun 1, 2023

What this PR does / why we need it:
This is a breaking API change to OpenStackClusterStatus. It makes 2 changes to status.Network. These are done in a single PR as they're somewhat related and can't be merged separately without conflicts. I have intentionally kept them in multiple commits.

The first change moves apiServerLoadBalancer and router out of status.network. These are not properties of the cluster network and may evolve separately in the future. Separating them now before v1beta1 reduces the scope of future churn.

The second change transforms network.subnet into a slice of subnets. This is in anticipation of dual stack support, which we hope to add to a future release based on v1beta1.

Special notes for your reviewer:
The multiple commits are deliberate. I don't intend to squash them. I recommend reviewing this PR by commit, as the changes are logically separate.

Where it was simpler to do so I have updated code to handle multiple subnets, but not in all places. This change doesn't intend to support multiple subnets. It simply allows the API to represent multiple subnets.

This does not represent all API changes required for dual stack support, only one of them.

/hold

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 1, 2023
@netlify
Copy link

netlify bot commented Jun 1, 2023

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

Name Link
🔨 Latest commit 802654e
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/6490a43af970b6000885c2a1
😎 Deploy Preview https://deploy-preview-1577--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 settings.

@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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 1, 2023
@mdbooth mdbooth marked this pull request as ready for review June 1, 2023 16:00
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 1, 2023
@k8s-ci-robot k8s-ci-robot requested a review from tobiasgiese June 1, 2023 16:00
@mdbooth
Copy link
Contributor Author

mdbooth commented Jun 1, 2023

/cc @dulek @MaysaMacedo

@k8s-ci-robot k8s-ci-robot requested a review from dulek June 1, 2023 16:03
@k8s-ci-robot
Copy link
Contributor

@mdbooth: GitHub didn't allow me to request PR reviews from the following users: maysamacedo.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @dulek @MaysaMacedo

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Comment on lines 162 to 168
// externalNetwork contains information about the external network used for default ingress and egress traffic.
ExternalNetwork *NetworkStatus `json:"externalNetwork,omitempty"`

// router describes the default cluster router
Router *Router `json:"router,omitempty"`

// apiServerLoadBalancer describes the api server load balancer if one exists
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment case should match variable case Router, ExternalNetwork, APIServerLoadBalancer and end with a dot.

The dot linter would be great but is unfortunately not reliable enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. I have no strong personal preference, but as our API astronauts in OpenShift always insist on using the json tag in API godocs I was assuming it was a documented convention. And it is, but the only reference I can find is for OpenShift specifically: https://github.com/openshift/enhancements/blob/master/dev-guide/api-conventions.md#use-json-field-names-in-godoc

The reasoning is that users see this output in kubectl explain, and only the json tags make sense in that context.

But... this isn't documented in kubernetes 🤔 The API Conventions don't have anything to say on the matter, and the coding conventions just point to the Go conventions, which obviously say to use the Go field. I'm genuinely surprised by that. I was kinda hoping to do a big API cleanup and change it everywhere so it's consistent, but now I'm wondering.

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think we don't even have to start with the object name itself. If we take a look at kubectl explain we can see that the name will be printed anyway.

Example

❯ k explain osc.spec | grep -A1 "^  network"
  network	<Object>
    If NodeCIDR cannot be set this can be used to detect an existing network.

If we want to keep the name in the comment I'd suggest to use the go notation and not the json tag.
But tbh, I don't really have a hard opinion on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On that there is a convention: https://www.kubernetes.dev/docs/guide/coding-convention/ points to https://go.dev/blog/godoc, which says:

Notice this comment is a complete sentence that begins with the name of the element it describes. This important convention allows us to generate documentation in a variety of formats, from plain text to HTML to UNIX man pages, and makes it read better when tools truncate it for brevity, such as when they extract the first line or sentence.

@@ -157,7 +157,7 @@ type OpenStackClusterStatus struct {

// Network contains all information about the created OpenStack Network.
// It includes Subnets and Router.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it still include Router?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope! I need to update that.

@seanschneeweiss
Copy link
Contributor

seanschneeweiss commented Jun 4, 2023

Consider setting label tide/merge-method-squash for keeping the commits.

@tobiasgiese
Copy link
Member

Consider setting label tide/merge-method-squash for keeping the commits.

@seanschneeweiss it‘s the other way around. Setting the squash label would squash the commits. The default merge behavior of Prow is a merge commit :)

Copy link
Contributor Author

@mdbooth mdbooth left a comment

Choose a reason for hiding this comment

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

Thanks, Sean!

@@ -157,7 +157,7 @@ type OpenStackClusterStatus struct {

// Network contains all information about the created OpenStack Network.
// It includes Subnets and Router.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope! I need to update that.

description: apiServerLoadBalancer describes the api server load balancer
if one exists
properties:
allowedCIDRs:
Copy link
Member

Choose a reason for hiding this comment

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

nit: it's maybe not part of this PR, but we should add a short description to all properties itself. kubectl explain is not very meaningful if we don't add descriptions.

❯ k explain osc.status.network.apiServerLoadBalancer
GROUP:      infrastructure.cluster.x-k8s.io
KIND:       OpenStackCluster
VERSION:    v1alpha5

FIELD: apiServerLoadBalancer <Object>

DESCRIPTION:
    Be careful when using APIServerLoadBalancer, because this field is optional
    and therefore not set in all cases
    
FIELDS:
  id	<string> -required-
    <no description>

  internalIP	<string> -required-
    <no description>

  ip	<string> -required-
    <no description>

  name	<string> -required-
    <no description>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For consistency I'm going to stick with Go type case for now. I thought we were obviously flouting a definite convention, which it seems we're not. As the cleanup is uncertain I'll stick with how most of them are currently defined.

@mdbooth
Copy link
Contributor Author

mdbooth commented Jun 19, 2023

This update rebases on to the latest main and updates some godocs as discussed above.

Copy link
Contributor

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

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

Looks good to me!
Leaving the hold for now so others have time to review
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 26, 2023
Copy link
Contributor

@seanschneeweiss seanschneeweiss left a comment

Choose a reason for hiding this comment

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

/lgtm

// It includes Subnets and Router.
Network *Network `json:"network,omitempty"`
// Network contains information about the created OpenStack Network.
Network *NetworkStatusWithSubnets `json:"network,omitempty"`

// externalNetwork contains information about the external network used for default ingress and egress traffic.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really part of your PR, would you mind changing that too?

Suggested change
// externalNetwork contains information about the external network used for default ingress and egress traffic.
// ExternalNetwork contains information about the external network used for default ingress and egress traffic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need a general godoc cleanup, tbh.

@mdbooth
Copy link
Contributor Author

mdbooth commented Jun 27, 2023

/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 Jun 27, 2023
@k8s-ci-robot k8s-ci-robot merged commit f968786 into kubernetes-sigs:main Jun 27, 2023
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants