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

⚠️Remove OpenStackMachineSpec.Subnet #1504

Merged
merged 1 commit into from
Mar 22, 2023

Conversation

mdbooth
Copy link
Contributor

@mdbooth mdbooth commented Mar 13, 2023

What this PR does / why we need it:
If set, OpenStackMachineSpec.Subnet must correspond to the subnet of at least 1 port on the machine. The IP in this subnet will be set as AccessIPv4 on the OpenStack server.

There are two principal problems with this API:

  • Users don't appear to be using it
  • It doesn't support IPv6

Supporting it adds complexity in code I would like to remove, so I propose removing it entirely.

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 13, 2023
@netlify
Copy link

netlify bot commented Mar 13, 2023

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

Name Link
🔨 Latest commit 211b5c4
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/641b20d2a1f03600086a010a
😎 Deploy Preview https://deploy-preview-1504--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 approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 13, 2023
@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 13, 2023

Tests blocked by kubernetes/test-infra#29003

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 13, 2023
@dulek
Copy link
Contributor

dulek commented Mar 13, 2023

How do we achieve the same thing that this API offered without the field?

@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 14, 2023

How do we achieve the same thing that this API offered without the field?

We don't: the functionality is removed. However, the premise of this change is that the functionality isn't useful. Do we know of anybody using it?

@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 14, 2023

/retest

@dulek
Copy link
Contributor

dulek commented Mar 15, 2023

What will be set as AccessIPv4 by default then? What effect does it have on the server? It's used by openstack server ssh?

@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 16, 2023

What will be set as AccessIPv4 by default then? What effect does it have on the server? It's used by openstack server ssh?

I don't think anybody's using it in practise. Even if they are it's an unnecessarily complex way to specify it and it doesn't support dual stack. I doubt we would bother, but if we did I'd prefer to implement a simpler way of achieving it in v1beta1.

@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 16, 2023

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

@dulek
Copy link
Contributor

dulek commented Mar 16, 2023

Okay, so https://codesearch.opendev.org/?q=access_ip_v4&i=nope&literal=nope&files=.*py&excludeFiles=&repos= tells me that the field has no real logic in Nova besides saving data. It has some in openstacksdk, but I don't think we care too much.

/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 16, 2023
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Mar 21, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 22, 2023
Comment on lines 28 to 83
// Convert a source object of type S to dest type D using the provided conversion function.
// Store the original source object in the dest object's annotations.
// Also return any previous version of the object stored in the source object's annotations.
func convertAndRestore[S, D metav1.Object](src S, dst D, previous D, convert func(S, D, conversion.Scope) error) (bool, error) {
// Restore data from previous conversion except for metadata.
// We do this before conversion because after convert() src.Annotations
// will be aliased as dst.Annotations and will therefore be modified by
// MarshalData below.
restored, err := utilconversion.UnmarshalData(src, previous)
if err != nil {
return false, err
}

func (r *OpenStackCluster) ConvertTo(dstRaw ctrlconversion.Hub) error {
dst := dstRaw.(*infrav1.OpenStackCluster)
if err := convert(src, dst, nil); err != nil {
return false, err
}

if err := Convert_v1alpha6_OpenStackCluster_To_v1alpha7_OpenStackCluster(r, dst, nil); err != nil {
return err
// Store the original source object in the dest object's annotations.
if err := utilconversion.MarshalData(src, dst); err != nil {
return false, err
}

// Manually restore data.
restored := &infrav1.OpenStackCluster{}
if ok, err := utilconversion.UnmarshalData(r, restored); err != nil || !ok {
return restored, nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lentzi90 This is the change to the conversion functions I was talking about.

With this in place I don't think we will have to ignore any fields in the fuzzer tests because all fields should either be losslessly convertible or restored from the stashed value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting! The first use of golang generics I have come across in the wild 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't know how you would write this without generics. I think it would just have to be boilerplate.

}))
}

// Test that mutation of a converted object survives a subsequent conversion.
func TestMutation(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lentzi90 This is the other test I was talking about which ensures that we don't simply overwrite an object with the stashed version on conversion.

@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 22, 2023

@lentzi90 This version is identical to the previous except for the addition of a HOW THIS WORKS section in conversion.go.

@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 22, 2023

@dulek This version just fixes api conversion from the version you previously reviewed.

@dulek
Copy link
Contributor

dulek commented Mar 22, 2023

/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 22, 2023
@mdbooth
Copy link
Contributor Author

mdbooth commented Mar 22, 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 Mar 22, 2023
@k8s-ci-robot k8s-ci-robot merged commit 3c12468 into kubernetes-sigs:main Mar 22, 2023
@mdbooth mdbooth deleted the subnet branch March 22, 2023 19:48
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants