Skip to content

Conversation

jsen-
Copy link
Contributor

@jsen- jsen- commented Mar 10, 2021

What this PR does / why we need it:
We need to assign additional ports to the created instances with vnic_type=direct.
Attempting to assign this port to an existing VM will fail, so it needs to be done during the VM creation.

Which issue(s) this PR fixes:
Fixes #788

Special notes for your reviewer:
This is a draft to start a conversation, maybe the goal can be achieved in a better way.

Release note:

Added the ability to create and assign additional ports

/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 10, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @jsen-. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 10, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jsen-
To complete the pull request process, please assign jichenjc after the PR has been reviewed.
You can assign the PR to them by writing /assign @jichenjc in a comment when ready.

The full list of commands accepted by this bot can be found 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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 10, 2021
@theopenlab-ci
Copy link

theopenlab-ci bot commented Mar 10, 2021

Build succeeded.

@jichenjc
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 11, 2021
@jichenjc
Copy link
Contributor

@jsen- I think I understand most of the code and purpose of this PR
can we create an issue to track the reason/purpose of the issue so that we can know more background ? Thanks

for _, portCreateOpts := range i.Ports {
port, err := getOrCreatePort(is, i.Name+"-"+portCreateOpts.NameSuffix, portCreateOpts)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

should we delete those ports when delete cluster? I assume those ports are independent to VM lifecylce?

Copy link
Member

Choose a reason for hiding this comment

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

I implemented a cleanup orphaned port logic in one of my PRs before the sec group deletion. But it would be good if we try to delete all ports during machine deletion which we created for this machine before.

@sbueringer
Copy link
Member

@jsen- I think I understand most of the code and purpose of this PR
can we create an issue to track the reason/purpose of the issue so that we can know more background ? Thanks

Yup, I would also like to understand why we need additional ports.

fyi. The v1alpha4 PR has been merged onto master. So if this feature is targeted towards master/v1alpha4 it has to
be implemented against the v1alpha4 CRDs now.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2021
@jsen-
Copy link
Contributor Author

jsen- commented Mar 16, 2021

Sorry for the delay, I'm actually out-of-office, but will try to be responsive.

can we create an issue to track the reason/purpose of the issue so that we can know more background ? Thanks

Done (#788)

should we delete those ports when delete cluster? I assume those ports are independent to VM lifecylce?

Definitely, I will try to implement cleanup of the ports and update the PR

So if this feature is targeted towards master/v1alpha4 it has to be implemented against the v1alpha4 CRDs now.

I'm assuming, rebase should be enough, am I correct?

@sbueringer
Copy link
Member

@jsen- More or less. You have to rebase onto master and make your changes in the api/v1alpha4 folder instead of api/v1alpha3 but the structs are almost the same so there shouldn't be a lot to adjust

@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 18, 2021
@@ -61,6 +61,9 @@ type OpenStackMachineSpec struct {
// UUID, IP address of a port from this subnet will be marked as AccessIPv4 on the created compute instance
Subnet string `json:"subnet,omitempty"`

// create and assign additional ports to instances
Ports []PortOpts `json:"ports,omitempty"`
Copy link
Contributor

@hidekazuna hidekazuna Mar 19, 2021

Choose a reason for hiding this comment

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

We only need VNICType actually. I try to find a light solution.
In my understanding, SR-IOV setting is done per compute node, but real use case is that create network for SR-IOV and create port for it. How about adding VNICType to NetworkParam? At least we can use existing network with SR-IOV.

Copy link
Contributor

@iamemilio iamemilio Mar 24, 2021

Choose a reason for hiding this comment

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

+1 Since Network param and Subnet Param are no longer nested in v1aplha4 api, it would also make sense to be able to set the vnicType in the subnet, in case that is a user's preferred way to add an interface to a compute instance.

Copy link
Member

Choose a reason for hiding this comment

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

I'm basically fine with whatever option you get consensus on :)
But just asking. We didn't change NetworkParam and SubnetParam from v1alpha4 and as far as I can see they are still nested. Did I miss something that they are not nested anymore ? :)

Copy link
Contributor

@iamemilio iamemilio Mar 25, 2021

Choose a reason for hiding this comment

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

I could be misunderstanding, but:

// A networks object. Required parameter when there are multiple networks defined for the tenant.
// When you do not specify the networks parameter, the server attaches to the only network created for the current tenant.
Networks []NetworkParam `json:"networks,omitempty"`
// UUID, IP address of a port from this subnet will be marked as AccessIPv4 on the created compute instance
Subnet string `json:"subnet,omitempty"`

It looks like they are their own isolated api entry. Its very possible that I am incorrect though. My frame of reference is from 4 api versions ago.

Copy link
Member

Choose a reason for hiding this comment

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

Ah now I get what lead to this assumption. This Subnet is only for the AccessIPv4 "selection". (it was introduced in #756)

SubnetParam is still nested.

type NetworkParam struct {
// The UUID of the network. Required if you omit the port attribute.
UUID string `json:"uuid,omitempty"`
// A fixed IPv4 address for the NIC.
FixedIP string `json:"fixedIp,omitempty"`
// Filters for optional network query
Filter Filter `json:"filter,omitempty"`
// Subnet within a network to use
Subnets []SubnetParam `json:"subnets,omitempty"`
}

As mentioned elsewhere we have to rethink our design / CRD sooner or later as it's not that thought out / consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah ok, that makes sense now. thanks for explaining!

@iamemilio
Copy link
Contributor

iamemilio commented Mar 24, 2021

Hi! We are actually working on something similar for RedHat OpenShift. Here is our work based off of a fork of the v1aplha1 API: openshift#170. The only difference in functionality between these two is that your patch does not account for allowing portSecurity to be set. I am not sure if this applies to other platforms, but in our platform, this would be a blocker. Other than that, where our implementation diverges the most is that we chose to automate the creation of the additional ports in the network and subnet param, but I do like your changes to allow for additional ports to be added explicitly.

I am hoping that we could align our work on this feature, since we are hoping to convert to v1alpha4, or potentially v1beta at some point in the future.

@jichenjc
Copy link
Contributor

I am hoping that we could align our work on this feature, since we are hoping to convert to v1alpha4, or potentially v1beta at some point in the future.

+1 to see this happen , thanks @iamemilio

@sbueringer
Copy link
Member

I am hoping that we could align our work on this feature, since we are hoping to convert to v1alpha4, or potentially v1beta at some point in the future.

+1 to see this happen , thanks @iamemilio

+1 for me too. I think this should be possible

@@ -116,6 +120,28 @@ type SubnetFilter struct {
NotTagsAny string `json:"notTagsAny,omitempty"`
}

type PortOpts struct {
NetworkID string `json:"networkId" required:"true"`
Copy link

@adduarte adduarte Mar 25, 2021

Choose a reason for hiding this comment

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

is there any value to adding a SubnetID field?
I would seem overkill, but there always seems to be a case where it would be nice to easily lookup the subnetID based on port. or the lookup ports based on subnetIDs

Copy link
Contributor

@iamemilio iamemilio Mar 25, 2021

Choose a reason for hiding this comment

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

Also, if your goal is to support SR-IOV, then you will need to be able to set (disable) portSecurity on the ports.

@iamemilio
Copy link
Contributor

iamemilio commented Mar 25, 2021

👾 Our team discussed things, and due to our timeline, we need to merge the patch in our fork for now so that we can unblock our quality assurance team. However, we are still going to collaborate with you on this feature and will also be filing a bug against our platform to ensure we meet feature and api parity with the results of this pull request. 😃

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 26, 2021
AllowedAddressPairs []ports.AddressPair `json:"allowedAddressPairs,omitempty"`

// The ID of the host where the port is allocated
HostID string `json:"binding:host_id,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
HostID string `json:"binding:host_id,omitempty"`
HostID string `json:"binding:hostID,omitempty"`

I would prefer to stick to camel case


// The virtual network interface card (vNIC) type that is bound to the
// neutron port.
VNICType string `json:"binding:vnic_type,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

^

@k8s-ci-robot
Copy link
Contributor

@jsen-: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-cluster-api-provider-openstack-test d453ee3 link /test pull-cluster-api-provider-openstack-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

TenantID string `json:"tenantID,omitempty"`
ProjectID string `json:"projectID,omitempty"`
SecurityGroups *[]string `json:"securityGroups,omitempty"`
AllowedAddressPairs []ports.AddressPair `json:"allowedAddressPairs,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

^ same as Fixed IPs :)

Sorry I keep hitting you with these so late. I missed these when reviewing and am bumping into them now that I am testing.

@@ -116,6 +120,26 @@ type SubnetFilter struct {
NotTagsAny string `json:"notTagsAny,omitempty"`
}

type PortOpts struct {
NetworkID string `json:"networkID" required:"true"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Since NetworkID is a mandatory field, would it make sense if ports: were children of the list items of networks:?

@sbueringer
Copy link
Member

@jsen- Please let me know if you are able to address this comments. I think we have a few other folks which would be happy to pick this up and geht it merged :)

@jsen-
Copy link
Contributor Author

jsen- commented May 14, 2021

@sbueringer apologies for the delays, we're still interested to get this into master, but I will be busy with other stuff for couple more weeks :( so don't mind if someone is willing to pick this up.

@sbueringer
Copy link
Member

@sbueringer apologies for the delays, we're still interested to get this into master, but I will be busy with other stuff for couple more weeks :( so don't mind if someone is willing to pick this up.

Okay, no problem. Thx for the information. @macaptain as you expressed interest (#788 (comment)), do you want to pick this up?

@macaptain
Copy link
Contributor

@sbueringer apologies for the delays, we're still interested to get this into master, but I will be busy with other stuff for couple more weeks :( so don't mind if someone is willing to pick this up.

Okay, no problem. Thx for the information. @macaptain as you expressed interest (#788 (comment)), do you want to pick this up?

Hey @sbueringer and @jsen- . Thanks for letting me know. Yes, I'd be happy to pick this up and try and get this feature into master.

@sbueringer
Copy link
Member

@macaptain Great! It probably makes sense to wait a bit until: #862 is merged as it refactors related code quite a bit. But this shouldn't take too long

@k8s-ci-robot
Copy link
Contributor

@jsen-: PR needs rebase.

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 15, 2021
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 21, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This commit is very much based on the work on @jsen-:

kubernetes-sigs#778

and also aims to bring Cluster API OpenStack provider into greater
alignment with the OpenShift fork.
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 21, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This commit is very much based on the work on @jsen-:

kubernetes-sigs#778

and also aims to bring Cluster API OpenStack provider into greater
alignment with the OpenShift fork.
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 21, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on @jsen-, and a lot of
credit has to go there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 21, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on @jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 21, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on @jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 21, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on @jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 21, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 24, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 28, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 31, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 31, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request May 31, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request Jun 1, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
macaptain added a commit to Nordix/cluster-api-provider-openstack that referenced this pull request Jun 7, 2021
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
@sbueringer
Copy link
Member

Can be closed as it has been implemented in #876
/close

(correct me if I'm wrong :))

@k8s-ci-robot
Copy link
Contributor

@sbueringer: Closed this PR.

In response to this:

Can be closed as it has been implemented in #876
/close

(correct me if I'm wrong :))

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.

pierreprinetti pushed a commit to shiftstack/cluster-api-provider-openstack that referenced this pull request Apr 22, 2024
This commit adds a new field to the v1alpha4 API:
OpenStackMachineTemplateSpec.ports.

The list of ports are added per instance. Each port may be customized
with options. These ports are created in addition to any ports created
in the `networks:` field.

If `networks:` is not specified, only the ports specified in `ports:`
will be created and attached to the instance. If neither `networks:` nor
`ports:` are specified, the instance will be connected to the default
cluster network and subnet.

This feature is very much based on the work on jsen-, and a lot of
credit goes there for the implementation:

kubernetes-sigs#778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

add the possibility to create custom ports
8 participants